@endel thanks .I have import @colyseus/social in my index.ts before dotenv
Posts made by Viveksharma
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
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 ");
}
}