mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
cleaned up the mess ... :)
This commit is contained in:
parent
ec1bceb1b6
commit
dd154aa576
6 changed files with 34 additions and 23 deletions
|
|
@ -5,11 +5,16 @@
|
|||
|
||||
function (GameController, NotificationCenter) {
|
||||
|
||||
function Channel (coordinatorLink) {
|
||||
function Channel (pipeToLobby) {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.coordinatorLink = coordinatorLink;
|
||||
this.coordinatorLink.receive = function (message) { self.onMessage(message) };
|
||||
this.pipeToLobby = pipeToLobby;
|
||||
|
||||
|
||||
//this.pipeToLobby.receive = function (message) { self.onMessage(message) };
|
||||
// !!! This should be done differently - use NotificationCenter.on('channel/dungeon/message') instead
|
||||
|
||||
|
||||
this.users = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,33 @@
|
|||
define([
|
||||
"Game/Core/NotficationCenter"
|
||||
"Game/Core/NotificationCenter",
|
||||
"Game/Server/Channel"
|
||||
],
|
||||
|
||||
function (NotficationCenter) {
|
||||
function (NotificationCenter, Channel) {
|
||||
|
||||
function PipeToLobby (process) {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.channel = null;
|
||||
this.process = process;
|
||||
|
||||
NotficationCenter.on('net/send', this.send, this);
|
||||
NotificationCenter.on('net/send', this.send, this);
|
||||
|
||||
process.on('message', function (message, handle) {
|
||||
|
||||
switch(message) {
|
||||
switch(message.data) {
|
||||
case 'CREATE':
|
||||
this.channel = new Channel(this);
|
||||
self.channel = new Channel(self);
|
||||
break;
|
||||
|
||||
case 'KILL':
|
||||
this.channel.destroy();
|
||||
self.channel.destroy();
|
||||
process.exit(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.onMessage(message);
|
||||
self.onMessage(message);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
@ -40,7 +43,7 @@ function (NotficationCenter) {
|
|||
};
|
||||
|
||||
PipeToLobby.prototype.onMessage = function (message) {
|
||||
NotficationCenter.trigger(message.recipient + '/message', message.data);
|
||||
NotificationCenter.trigger(message.recipient + '/message', message.data);
|
||||
}
|
||||
|
||||
return PipeToLobby;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue