mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
46 lines
No EOL
1.1 KiB
JavaScript
Executable file
46 lines
No EOL
1.1 KiB
JavaScript
Executable file
define([
|
|
"Lib/Utilities/NotificationCenter",
|
|
"Game/Server/Channel"
|
|
],
|
|
|
|
function (NotificationCenter, Channel) {
|
|
|
|
function PipeToLobby (process) {
|
|
|
|
var self = this;
|
|
|
|
this.channel = null;
|
|
this.process = process;
|
|
|
|
NotificationCenter.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);
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
PipeToLobby.prototype.send = function (recipient, data) {
|
|
var message = {
|
|
recipient: recipient,
|
|
data: data
|
|
}
|
|
|
|
this.process.send(message);
|
|
};
|
|
|
|
PipeToLobby.prototype.onMessage = function (message) {
|
|
NotificationCenter.trigger(message.recipient + '/controlCommand', message);
|
|
}
|
|
|
|
return PipeToLobby;
|
|
|
|
}); |