mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
messed everything up .... :( 111
This commit is contained in:
parent
03678eb773
commit
ec1bceb1b6
13 changed files with 145 additions and 117 deletions
|
|
@ -1,20 +0,0 @@
|
|||
define([
|
||||
],
|
||||
|
||||
function () {
|
||||
|
||||
function CoordinatorLink (process) {
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
CoordinatorLink.prototype.send = function (message) {
|
||||
this.process.send(message);
|
||||
};
|
||||
|
||||
CoordinatorLink.prototype.receive = function (message) {
|
||||
throw 'This method is abstract and must be overwritten by Channel';
|
||||
};
|
||||
|
||||
return CoordinatorLink;
|
||||
|
||||
});
|
||||
48
app/Game/Server/PipeToLobby.js
Executable file
48
app/Game/Server/PipeToLobby.js
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
define([
|
||||
"Game/Core/NotficationCenter"
|
||||
],
|
||||
|
||||
function (NotficationCenter) {
|
||||
|
||||
function PipeToLobby (process) {
|
||||
|
||||
this.channel = null;
|
||||
this.process = process;
|
||||
|
||||
NotficationCenter.on('net/send', this.send, this);
|
||||
|
||||
process.on('message', function (message, handle) {
|
||||
|
||||
switch(message) {
|
||||
case 'CREATE':
|
||||
this.channel = new Channel(this);
|
||||
break;
|
||||
|
||||
case 'KILL':
|
||||
this.channel.destroy();
|
||||
process.exit(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.onMessage(message);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PipeToLobby.prototype.send = function (recipient, data) {
|
||||
var message = {
|
||||
recipient: recipient,
|
||||
data: data
|
||||
}
|
||||
|
||||
this.process.send(message);
|
||||
};
|
||||
|
||||
PipeToLobby.prototype.onMessage = function (message) {
|
||||
NotficationCenter.trigger(message.recipient + '/message', message.data);
|
||||
}
|
||||
|
||||
return PipeToLobby;
|
||||
|
||||
});
|
||||
|
|
@ -6,8 +6,8 @@ define([
|
|||
|
||||
function (Parent, ProtocolHelper, NotificationCenter) {
|
||||
|
||||
function User (id, coordinator) {
|
||||
Parent.call(this, id);
|
||||
function User (socketLink, coordinator) {
|
||||
Parent.call(this, socketLink.id);
|
||||
this.id = socketLink.id;
|
||||
this.socketLink = socketLink;
|
||||
this.coordinator = coordinator;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue