mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
ground work for different users on server and players on client
This commit is contained in:
parent
e37d1eeb2e
commit
2cb401bbd3
9 changed files with 122 additions and 54 deletions
|
|
@ -7,19 +7,19 @@ define(["Protocol/Helper", "Chuck/ClientGame"], function(ProtocolHelper, ClientG
|
|||
this.init();
|
||||
}
|
||||
|
||||
Networker.prototype.init = function(){
|
||||
Networker.prototype.init = function() {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.socketLink.on('connect', function(){
|
||||
this.socketLink.on('connect', function() {
|
||||
self.onConnect();
|
||||
});
|
||||
|
||||
this.socketLink.on('message', function(message){
|
||||
this.socketLink.on('message', function(message) {
|
||||
self.onMessage(message);
|
||||
});
|
||||
|
||||
this.socketLink.on('disconnect', function(){
|
||||
this.socketLink.on('disconnect', function() {
|
||||
self.onDisconnect();
|
||||
});
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ define(["Protocol/Helper", "Chuck/ClientGame"], function(ProtocolHelper, ClientG
|
|||
|
||||
Networker.prototype.onMessage = function(message) {
|
||||
var self = this;
|
||||
ProtocolHelper.runCommands(message, function(command, options){
|
||||
ProtocolHelper.runCommands(message, function(command, options) {
|
||||
self.processControlCommand(command, options);
|
||||
});
|
||||
}
|
||||
|
|
@ -49,18 +49,18 @@ define(["Protocol/Helper", "Chuck/ClientGame"], function(ProtocolHelper, ClientG
|
|||
this.socketLink.send(message);
|
||||
}
|
||||
|
||||
Networker.prototype.onJoinSuccess = function(channelName) {
|
||||
this.clientGame = new ClientGame(this);
|
||||
Networker.prototype.onJoinSuccess = function(options) {
|
||||
this.clientGame = new ClientGame(this, options.id);
|
||||
this.clientGame.loadLevel("default.json")
|
||||
console.log("Joined " + channelName);
|
||||
console.log("Joined " + options.channelName);
|
||||
}
|
||||
|
||||
Networker.prototype.onUserJoined = function(userId) {
|
||||
//this.clientGame.userJoined(userId);
|
||||
this.clientGame.userJoined(userId);
|
||||
console.log("User " + userId + " joined");
|
||||
};
|
||||
|
||||
Networker.prototype.processControlCommand = function(command, options){
|
||||
Networker.prototype.processControlCommand = function(command, options) {
|
||||
switch(command) {
|
||||
case 'joinSuccess':
|
||||
this.onJoinSuccess(options);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue