|
|
@ -68,7 +68,7 @@ var sendChannelMessage = function (ctx, channel, msg, cb) {
|
|
|
|
sendMsg(msg, user.socket);
|
|
|
|
sendMsg(msg, user.socket);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e.stack);
|
|
|
|
console.log(e.stack);
|
|
|
|
dropClient(ctx, userPass);
|
|
|
|
try { dropClient(ctx, user.userPass); } catch (e) { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
cb && cb();
|
|
|
|
cb && cb();
|
|
|
@ -124,12 +124,13 @@ var handleMessage = function (ctx, socket, msg) {
|
|
|
|
if (parsed.content[0] === REGISTER) {
|
|
|
|
if (parsed.content[0] === REGISTER) {
|
|
|
|
if (parsed.user.length === 0) { throw new Error(); }
|
|
|
|
if (parsed.user.length === 0) { throw new Error(); }
|
|
|
|
console.log("[" + userPass + "] registered");
|
|
|
|
console.log("[" + userPass + "] registered");
|
|
|
|
var client = ctx.registeredClients[userPass] = ctx.registeredClients[userPass] || {
|
|
|
|
var user = ctx.registeredClients[userPass] = ctx.registeredClients[userPass] || {
|
|
|
|
channels: [parsed.channelId],
|
|
|
|
channels: [parsed.channelId],
|
|
|
|
userName: parsed.user
|
|
|
|
userName: parsed.user
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (client.socket && client.socket !== socket) { client.socket.close(); }
|
|
|
|
if (user.socket && user.socket !== socket) { user.socket.close(); }
|
|
|
|
client.socket = socket;
|
|
|
|
user.socket = socket;
|
|
|
|
|
|
|
|
user.userPass = userPass;
|
|
|
|
|
|
|
|
|
|
|
|
var chan = ctx.channels[parsed.channelId] = ctx.channels[parsed.channelId] || [];
|
|
|
|
var chan = ctx.channels[parsed.channelId] = ctx.channels[parsed.channelId] || [];
|
|
|
|
var newChan = (chan.length === 0);
|
|
|
|
var newChan = (chan.length === 0);
|
|
|
|