Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. Viveksharma
    3. Posts
    • Profile
    • More
      • Continue chat with Viveksharma
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by Viveksharma

    RE: process.env.MONGO_URI not working as expected in colyseus social package

    @endel thanks .I have import @colyseus/social in my index.ts before dotenv

    posted in Questions & Help •
    process.env.MONGO_URI not working as expected in colyseus social package

    I am trying to use colyseus social package and I set MONGO_URI as expected via process.env.MONGO_URI in my index.ts but while colyseus server going to make a connection with mongodb it is getting default value(old value) although process.env.MONGO_URI updated to new value.

    I tried to check it in connectDatabase method of index.ts in social module and console like :-

    import { MONGO_URI } from "./env";

    export async function connectDatabase(cb?: (err: MongoError) => void) {
    // skip if already connecting or connected.
    if (mongoose.connection.readyState !== 0) {
    if (cb) cb(null);
    return;
    }

    try {
        console.log(process.env.MONGO_URI);// getting updated value
        console.log(MONGO_URI);//getting old value
        await mongoose.connect(MONGO_URI, { autoIndex: false, useNewUrlParser: true }, cb);
        debug(`Successfully connected to ${MONGO_URI}`)
    
        // reconnect if disconnected.
        mongoose.connection.on('disconnected', () => connectDatabase());
    } catch (e) {
        console.error('Error connecting to database: ', e);
    }
    

    }

    Please help it out . Thanks in advance

    posted in Questions & Help •
    RE: Client joined even authentication failed after upgrading to version 0.11.0?

    @endel thanks

    posted in Questions & Help •
    Client joined even authentication failed after upgrading to version 0.11.0?

    Inside RoomHandler, OnJoin should be called iff onAuth executed successfully with returning true but i am returning false but still my player able to join my room.

    Is something changed in new version or it is a bug? or may be i am understood something wrong.

    export class MyRoom extends Room<State>
    {

    onCreate(options: any) {
    }
    
    
    onAuth(client: Client, options: any) {
        return false;
    }
    
    onJoin(client: Client, options?: any, auth?: any) {
        console.log("client joined ");
    
    }
    

    }

    posted in Questions & Help •