mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
fixed client removal, joining, etc.
This commit is contained in:
parent
2183e70bd8
commit
69fd43a900
6 changed files with 69 additions and 50 deletions
|
|
@ -13,17 +13,28 @@ function(Parent, NotificationCenter, ProtocolHelper) {
|
|||
var self = this;
|
||||
|
||||
NotificationCenter.on('user/joined', function(user) {
|
||||
self.sendCommand("joined", true);
|
||||
if(user.id != self.id) {
|
||||
self.sendControlCommand("userJoined", user.id);
|
||||
}
|
||||
});
|
||||
|
||||
NotificationCenter.on('user/' + this.id + "/joinSuccess", function(options) {
|
||||
self.sendControlCommand("joinSuccess", options);
|
||||
});
|
||||
}
|
||||
|
||||
User.prototype = Object.create(Parent.prototype);
|
||||
|
||||
User.prototype.sendCommand = function(command, options) {
|
||||
User.prototype.sendControlCommand = function(command, options) {
|
||||
var recipient = "user/" + this.id;
|
||||
var data = ProtocolHelper.encodeCommand(command, options);
|
||||
|
||||
NotificationCenter.trigger("net/send", recipient, data);
|
||||
NotificationCenter.trigger("process/message", recipient, data);
|
||||
};
|
||||
|
||||
User.prototype.sendGameCommand = function(command, options) {
|
||||
var data = ProtocolHelper.encodeCommand(command, options);
|
||||
this.sendControlCommand("gameCommand", data);
|
||||
};
|
||||
|
||||
return User;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue