mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed #58
This commit is contained in:
parent
d83376d5c7
commit
810a74a28b
13 changed files with 445 additions and 281 deletions
|
|
@ -20,7 +20,8 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
|
||||
var self = this;
|
||||
this.socketLink.on('message', function (message) {
|
||||
if(Settings.NETWORK_LOG_INCOMING) {
|
||||
var m = JSON.parse(message)
|
||||
if(Settings.NETWORK_LOG_INCOMING && !m.gameCommand) {
|
||||
console.log('INCOMING', message);
|
||||
}
|
||||
ProtocolHelper.applyCommand(message, self);
|
||||
|
|
@ -35,8 +36,13 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
Networker.prototype.onConnect = function () {
|
||||
console.log('connected.')
|
||||
var channel = JSON.parse(localStorage["channel"]);
|
||||
var player = JSON.parse(localStorage["player"]);
|
||||
if(channel.name) {
|
||||
this.sendCommand('join', channel.name);
|
||||
var options = {
|
||||
channelName: channel.name,
|
||||
nickname: player.nickname
|
||||
}
|
||||
this.sendCommand('join', options);
|
||||
} else {
|
||||
window.location.href = "/";
|
||||
}
|
||||
|
|
@ -67,6 +73,11 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
this.initPing();
|
||||
}
|
||||
|
||||
Networker.prototype.onJoinError = function(options) {
|
||||
alert(options.message);
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
Networker.prototype.onLevelLoaded = function() {
|
||||
for (var userId in this.users) {
|
||||
this.gameController.createPlayer(this.users[userId]);
|
||||
|
|
@ -116,8 +127,7 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
}
|
||||
|
||||
Networker.prototype.onUserLeft = function (userId) {
|
||||
var user = this.users[userId];
|
||||
this.gameController.onUserLeft(user);
|
||||
this.gameController.onUserLeft(userId);
|
||||
delete this.users[userId];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue