messed everything up .... :( 111

This commit is contained in:
logsol 2012-07-28 21:09:39 +02:00
parent 03678eb773
commit ec1bceb1b6
13 changed files with 145 additions and 117 deletions

38
app/Lobby/PipeToChannel.js Executable file
View file

@ -0,0 +1,38 @@
define([
"Game/Core/NotificationCenter"
],
function (NotificationCenter) {
function PipeToChannel (channelName) {
this.channelProcess = null;
try {
this.channelProcess = fork('channel.js');
} catch (err) {
throw 'Failed to fork channel! (' + err + ')';
}
this.send('channel/' + channelName, 'CREATE');
this.channelProcess.on('message', this.onMessage.bind(this));
var self = this;
}
PipeToChannel.prototype.send = function (recipient, data) {
var message = {
recipient: recipient,
data: data
}
this.channelProcess.send(message);
}
PipeToChannel.prototype.onMessage = function (message) {
NotficationCenter.trigger(message.recipient + '/message', message.data);
}
return PipeToChannel;
});