diff --git a/brainlet/api/v2/gateway/index.js b/brainlet/api/v2/gateway/index.js index 54bc85f..407b304 100644 --- a/brainlet/api/v2/gateway/index.js +++ b/brainlet/api/v2/gateway/index.js @@ -123,24 +123,26 @@ class GatewayServer extends EventEmitter { let presence = {}; const channel = channels[0]; - this.inChannel(channel._id, (client) => { - presence[client.session.user._id] = { - _id: client.session.user._id, - username: client.session.user.username, - status: 1, - status_text: "Online" - }; - if (client.session.sessionId !== ws.session.sessionId) client.send(packet("EVENT_CHANNEL_MEMBERS", { - [ws.session.user._id]: { - _id: ws.session.user._id, - username: ws.session.user.username, + if (channel) { + this.inChannel(channel._id, (client) => { + presence[client.session.user._id] = { + _id: client.session.user._id, + username: client.session.user.username, status: 1, status_text: "Online" - } - })); - }); + }; + if (client.session.sessionId !== ws.session.sessionId) client.send(packet("EVENT_CHANNEL_MEMBERS", { + [ws.session.user._id]: { + _id: ws.session.user._id, + username: ws.session.user.username, + status: 1, + status_text: "Online" + } + })); + }); - ws.send(packet("EVENT_CHANNEL_MEMBERS", presence)); + ws.send(packet("EVENT_CHANNEL_MEMBERS", presence)); + } console.log(`gateway: user ${user.username}: handshake complete`); } catch (e) { diff --git a/brainlet/config.js b/brainlet/config.js index d78d8f5..7d5a62c 100755 --- a/brainlet/config.js +++ b/brainlet/config.js @@ -2,20 +2,20 @@ module.exports = { ports: { mainServerPort: 3005, }, - address: 'localhost', + address: "localhost", //restrictions: { // signup: { // specialCode: '' // } //}, - mongoUrl: 'mongodb://192.168.0.105:27017/app', + mongoUrl: "mongodb://127.0.0.1:27017/app", bcryptRounds: 10, roleMap: { - 'BANNED': 0, - 'RESTRICTED': 1, - 'USER': 2, - 'BOT': 3, - 'ADMIN': 4 + "BANNED": 0, + "RESTRICTED": 1, + "USER": 2, + "BOT": 3, + "ADMIN": 4 }, gatewayStillNotConnectedTimeoutMS: 15*1000 };