mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
implemented channel forking
This commit is contained in:
parent
815c63009f
commit
25653b4d58
4 changed files with 33 additions and 16 deletions
|
|
@ -1,8 +1,9 @@
|
|||
define([
|
||||
"Game/Server/Channel"
|
||||
"Game/Server/Channel",
|
||||
"Game/Server/CoordinatorLink"
|
||||
],
|
||||
|
||||
function(Channel) {
|
||||
function(Channel, CoordinatorLink) {
|
||||
|
||||
function ChannelBootstrap(process) {
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 + ')';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
console.log(requirejs);
|
||||
|
||||
|
||||
var ree = require('requirejs');
|
||||
|
||||
console.log(ree);
|
||||
var requirejs = require('requirejs');
|
||||
|
||||
requirejs.config({
|
||||
baseUrl: 'app'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue