mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
refactored Server and Lobby
This commit is contained in:
parent
42475c9b38
commit
d83376d5c7
26 changed files with 29 additions and 29 deletions
46
app/Game/Channel/PipeToServer.js
Executable file
46
app/Game/Channel/PipeToServer.js
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
define([
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Game/Channel/Channel"
|
||||
],
|
||||
|
||||
function (Nc, Channel) {
|
||||
|
||||
function PipeToServer (process) {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.channel = null;
|
||||
this.process = process;
|
||||
|
||||
Nc.on('process/message', this.send, this);
|
||||
|
||||
process.on('message', function (message, handle) {
|
||||
|
||||
if(message.data.hasOwnProperty('CREATE')) {
|
||||
self.channel = new Channel(this, message.data['CREATE']);
|
||||
} else if (message.data.hasOwnProperty('KILL')) {
|
||||
self.channel.destroy();
|
||||
process.exit(0);
|
||||
} else {
|
||||
self.onMessage(message);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
PipeToServer.prototype.send = function (recipient, data) {
|
||||
var message = {
|
||||
recipient: recipient,
|
||||
data: data
|
||||
}
|
||||
|
||||
this.process.send(message);
|
||||
};
|
||||
|
||||
PipeToServer.prototype.onMessage = function (message) {
|
||||
Nc.trigger(message.recipient + '/controlCommand', message);
|
||||
}
|
||||
|
||||
return PipeToServer;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue