"REGISTRATIONACCEPTED": function(){ setSetting('name', this.registering.name); setSetting('password', this.registering.password); Server.disconnect(); Server.connect(); return true; },
pingPong: function(){ if (this.lostPings > 4){ this.lostPings = 0; Log.errorBox('Lost connection to server. Trying to reconnect...'); Server.disconnect(); Server.connect(); } else if (this.connection === this.ConnectionState.CONNECTED){ this.send('PING'); this.lostPings++; } },
"RegisterResponse": function(msg){ if (msg.ResultCode === LoginResponse.Ok) { setSetting('name', this.registering.name); setSetting('password', this.registering.password); Server.disconnect(); Server.connect(); } else { Log.errorBox('Registration denied: ' + this.loginResponseToText(msg.ResultCode) + (msg.Reason ? '\n' + msg.Reason : '')); this.needNewLogin = true; Server.disconnect(); } return true; },
acceptAgreement: function(accept){ if (accept){ this.send('CONFIRMAGREEMENT'); this.login(); } else { Server.disconnect(); } this.agreement = ''; this.triggerSync(); },
"LoginResponse": function(msg){ if (msg.ResultCode === LoginResponse.Ok) { this.connection = this.ConnectionState.CONNECTED; this.autoJoinChannels(); } else { Log.errorBox('Login denied: ' + this.loginResponseToText(msg.ResultCode) + (msg.Reason ? '\n' + msg.Reason : '')); this.needNewLogin = true; Server.disconnect(); } },
"Say": function(msg){ var date = msg.Time && new Date(msg.Time); if (msg.Place === SayPlace.Channel) Chat.saidChannel(msg.Target, msg.User, msg.Text, msg.IsEmote, date || undefined); else if (msg.Place === SayPlace.User && msg.User === this.nick) Chat.sentPrivate(msg.Target, msg.Text, msg.IsEmote); else if (msg.Place === SayPlace.User) Chat.saidPrivate(msg.User, msg.Text, msg.IsEmote, date || undefined); else if (msg.Place === SayPlace.Battle) Chat.saidBattle(msg.User, msg.Text, msg.IsEmote); else if (msg.Place === SayPlace.BattlePrivate) Chat.saidBattle(msg.User, msg.Text, true); if (msg.Place === SayPlace.BattlePrivate && msg.Ring === true) Server.ringed(); return true; },
send: function(msg){ Settings.dumpNetwork && Log.debug("[OUT] " + msg); Server.sendRaw(msg); },
"RING": function(){ Server.ringed(); return true; },
"REGISTRATIONDENIED": function(reason){ Log.errorBox('Registration denied: ' + reason); this.needNewLogin = true; Server.disconnect(); },
"DENIED": function(reason){ Log.errorBox('Login denied: ' + reason); this.needNewLogin = true; Server.disconnect(); },
send: function(message, payload){ var str = message + ' ' + JSON.stringify(payload); Settings.dumpNetwork && Log.debug("[OUT] " + str); Server.sendRaw(str); },