implemented channel forking

This commit is contained in:
logsol 2012-07-22 18:50:44 +02:00
parent 815c63009f
commit 25653b4d58
4 changed files with 33 additions and 16 deletions

View file

@ -1,8 +1,9 @@
define([
"Game/Server/Channel"
"Game/Server/Channel",
"Game/Server/CoordinatorLink"
],
function(Channel) {
function(Channel, CoordinatorLink) {
function ChannelBootstrap(process) {

View file

@ -8,13 +8,12 @@ function(GameController, NotificationCenter) {
function Channel(coordinatorLink) {
this.coordinatorLink = coordinatorLink;
this.coordinatorLink.receive = this.onMessage;
console.log('A CHANNEL WAS CREATED');
/*
this.users = {};
this.gameController = new GameController();
this.gameController.loadLevel("default.json");
*/
/*
var self = this;
NotificationCenter.on("processGameCommandFromUser", function(topic, args) {
@ -26,6 +25,23 @@ function(GameController, NotificationCenter) {
Channel.validateName = function(name){
return true;
}
Channel.prototype.onMessage = function(message) {
for(var recipient in message) {
switch(recipient) {
case 'user':
this.users[message.id].onMessage(message.user);
break;
case 'channel':
this.onMessage(message.channel);
break;
default:
throw 'unknown recipient';
break;
}
}
};
/*
Channel.prototype.addUser = function(user){
var userIds = Object.keys(this.users);

View file

@ -40,10 +40,15 @@ function(User, Channel, nodeFork) {
if(!channel) {
try {
console.log('try');
channel = fork('app/Bootstrap/Channel.js');
channel = fork('channel.js');
channel.send('CREATE');
channel.send('{setName:"' + channelName + '"}');
channel.send({
channel: {
setName: channelName
}
});
} catch (err) {
throw 'Failed to fork channel ' + channelName + '! (' + err + ')';
}

View file

@ -1,9 +1,4 @@
console.log(requirejs);
var ree = require('requirejs');
console.log(ree);
var requirejs = require('requirejs');
requirejs.config({
baseUrl: 'app'