From d83376d5c73e8338f5686536f0cc94ff3d1c895b Mon Sep 17 00:00:00 2001 From: Jeena Date: Sat, 1 Mar 2014 14:07:03 +0100 Subject: [PATCH] refactored Server and Lobby --- app/Bootstrap/HttpServer.js | 2 +- app/Game/{Server => Channel}/Channel.js | 8 ++++---- app/Game/{Server => Channel}/Collision/Detector.js | 0 .../{Server => Channel}/Control/PlayerController.js | 0 app/Game/{Server => Channel}/GameController.js | 12 ++++++------ app/Game/{Server => Channel}/GameObjects/Doll.js | 2 +- .../{Server => Channel}/GameObjects/GameObject.js | 0 app/Game/{Server => Channel}/GameObjects/Item.js | 0 .../{Server => Channel}/GameObjects/Items/RagDoll.js | 0 .../GameObjects/Items/Skateboard.js | 0 .../{Server => Channel}/GameObjects/SpectatorDoll.js | 0 app/Game/{Server => Channel}/GameObjects/Tile.js | 0 app/Game/{Server => Channel}/Loader/Level.js | 0 app/Game/{Server => Channel}/Loader/TiledLevel.js | 0 app/Game/{Server => Channel}/Physics/Engine.js | 0 .../PipeToLobby.js => Channel/PipeToServer.js} | 10 +++++----- app/Game/{Server => Channel}/Player.js | 0 app/Game/{Server => Channel}/User.js | 0 app/Lib/Utilities/Extensions.js | 2 +- app/Lib/Utilities/NotificationCenter.js | 2 +- app/{Lobby => Server}/Api.js | 0 app/{Lobby => Server}/Coordinator.js | 6 +++--- app/{Lobby => Server}/PipeToChannel.js | 0 app/{Lobby => Server}/User.js | 0 channel.js | 10 +++++----- server.js | 4 ++-- 26 files changed, 29 insertions(+), 29 deletions(-) rename app/Game/{Server => Channel}/Channel.js (95%) rename app/Game/{Server => Channel}/Collision/Detector.js (100%) rename app/Game/{Server => Channel}/Control/PlayerController.js (100%) rename app/Game/{Server => Channel}/GameController.js (96%) rename app/Game/{Server => Channel}/GameObjects/Doll.js (98%) rename app/Game/{Server => Channel}/GameObjects/GameObject.js (100%) rename app/Game/{Server => Channel}/GameObjects/Item.js (100%) rename app/Game/{Server => Channel}/GameObjects/Items/RagDoll.js (100%) rename app/Game/{Server => Channel}/GameObjects/Items/Skateboard.js (100%) rename app/Game/{Server => Channel}/GameObjects/SpectatorDoll.js (100%) rename app/Game/{Server => Channel}/GameObjects/Tile.js (100%) rename app/Game/{Server => Channel}/Loader/Level.js (100%) rename app/Game/{Server => Channel}/Loader/TiledLevel.js (100%) rename app/Game/{Server => Channel}/Physics/Engine.js (100%) rename app/Game/{Server/PipeToLobby.js => Channel/PipeToServer.js} (77%) rename app/Game/{Server => Channel}/Player.js (100%) rename app/Game/{Server => Channel}/User.js (100%) rename app/{Lobby => Server}/Api.js (100%) rename app/{Lobby => Server}/Coordinator.js (97%) rename app/{Lobby => Server}/PipeToChannel.js (100%) rename app/{Lobby => Server}/User.js (100%) diff --git a/app/Bootstrap/HttpServer.js b/app/Bootstrap/HttpServer.js index e333b45..b2a7183 100755 --- a/app/Bootstrap/HttpServer.js +++ b/app/Bootstrap/HttpServer.js @@ -1,7 +1,7 @@ define([ 'http', 'node-static', - 'Lobby/Api' + 'Server/Api' ], function (http, nodeStatic, Api) { diff --git a/app/Game/Server/Channel.js b/app/Game/Channel/Channel.js similarity index 95% rename from app/Game/Server/Channel.js rename to app/Game/Channel/Channel.js index a422c26..28bb2f2 100755 --- a/app/Game/Server/Channel.js +++ b/app/Game/Channel/Channel.js @@ -1,7 +1,7 @@ define([ - "Game/Server/GameController", + "Game/Channel/GameController", "Lib/Utilities/NotificationCenter", - "Game/Server/User", + "Game/Channel/User", "Lib/Utilities/Protocol/Helper", "Lib/Utilities/Options", "Game/Config/Settings" @@ -9,7 +9,7 @@ function (GameController, Nc, User, ProtocolHelper, Options, Settings) { - function Channel (pipeToLobby, name, options) { + function Channel (pipeToServer, name, options) { var self = this; @@ -20,7 +20,7 @@ this.name = name; this.users = {}; - this.pipeToLobby = pipeToLobby; + this.pipeToServer = pipeToServer; this.gameController = new GameController(this); diff --git a/app/Game/Server/Collision/Detector.js b/app/Game/Channel/Collision/Detector.js similarity index 100% rename from app/Game/Server/Collision/Detector.js rename to app/Game/Channel/Collision/Detector.js diff --git a/app/Game/Server/Control/PlayerController.js b/app/Game/Channel/Control/PlayerController.js similarity index 100% rename from app/Game/Server/Control/PlayerController.js rename to app/Game/Channel/Control/PlayerController.js diff --git a/app/Game/Server/GameController.js b/app/Game/Channel/GameController.js similarity index 96% rename from app/Game/Server/GameController.js rename to app/Game/Channel/GameController.js index c40ef36..e447fae 100755 --- a/app/Game/Server/GameController.js +++ b/app/Game/Channel/GameController.js @@ -1,15 +1,15 @@ define([ "Game/Core/GameController", - "Game/Server/Physics/Engine", + "Game/Channel/Physics/Engine", "Game/Config/Settings", - "Game/Server/Control/PlayerController", + "Game/Channel/Control/PlayerController", "Lib/Utilities/RequestAnimFrame", "Lib/Utilities/NotificationCenter", "Lib/Vendor/Box2D", - "Game/Server/Player", - "Game/Server/GameObjects/GameObject", - "Game/Server/GameObjects/Doll", - "Game/Server/GameObjects/Items/RagDoll" + "Game/Channel/Player", + "Game/Channel/GameObjects/GameObject", + "Game/Channel/GameObjects/Doll", + "Game/Channel/GameObjects/Items/RagDoll" ], function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, Nc, Box2D, Player, GameObject, Doll, RagDoll) { diff --git a/app/Game/Server/GameObjects/Doll.js b/app/Game/Channel/GameObjects/Doll.js similarity index 98% rename from app/Game/Server/GameObjects/Doll.js rename to app/Game/Channel/GameObjects/Doll.js index 4d2738d..8349094 100755 --- a/app/Game/Server/GameObjects/Doll.js +++ b/app/Game/Channel/GameObjects/Doll.js @@ -1,6 +1,6 @@ define([ "Game/Core/GameObjects/Doll", - "Game/Server/GameObjects/Item", + "Game/Channel/GameObjects/Item", "Lib/Vendor/Box2D", "Lib/Utilities/NotificationCenter" ], diff --git a/app/Game/Server/GameObjects/GameObject.js b/app/Game/Channel/GameObjects/GameObject.js similarity index 100% rename from app/Game/Server/GameObjects/GameObject.js rename to app/Game/Channel/GameObjects/GameObject.js diff --git a/app/Game/Server/GameObjects/Item.js b/app/Game/Channel/GameObjects/Item.js similarity index 100% rename from app/Game/Server/GameObjects/Item.js rename to app/Game/Channel/GameObjects/Item.js diff --git a/app/Game/Server/GameObjects/Items/RagDoll.js b/app/Game/Channel/GameObjects/Items/RagDoll.js similarity index 100% rename from app/Game/Server/GameObjects/Items/RagDoll.js rename to app/Game/Channel/GameObjects/Items/RagDoll.js diff --git a/app/Game/Server/GameObjects/Items/Skateboard.js b/app/Game/Channel/GameObjects/Items/Skateboard.js similarity index 100% rename from app/Game/Server/GameObjects/Items/Skateboard.js rename to app/Game/Channel/GameObjects/Items/Skateboard.js diff --git a/app/Game/Server/GameObjects/SpectatorDoll.js b/app/Game/Channel/GameObjects/SpectatorDoll.js similarity index 100% rename from app/Game/Server/GameObjects/SpectatorDoll.js rename to app/Game/Channel/GameObjects/SpectatorDoll.js diff --git a/app/Game/Server/GameObjects/Tile.js b/app/Game/Channel/GameObjects/Tile.js similarity index 100% rename from app/Game/Server/GameObjects/Tile.js rename to app/Game/Channel/GameObjects/Tile.js diff --git a/app/Game/Server/Loader/Level.js b/app/Game/Channel/Loader/Level.js similarity index 100% rename from app/Game/Server/Loader/Level.js rename to app/Game/Channel/Loader/Level.js diff --git a/app/Game/Server/Loader/TiledLevel.js b/app/Game/Channel/Loader/TiledLevel.js similarity index 100% rename from app/Game/Server/Loader/TiledLevel.js rename to app/Game/Channel/Loader/TiledLevel.js diff --git a/app/Game/Server/Physics/Engine.js b/app/Game/Channel/Physics/Engine.js similarity index 100% rename from app/Game/Server/Physics/Engine.js rename to app/Game/Channel/Physics/Engine.js diff --git a/app/Game/Server/PipeToLobby.js b/app/Game/Channel/PipeToServer.js similarity index 77% rename from app/Game/Server/PipeToLobby.js rename to app/Game/Channel/PipeToServer.js index 33dc741..396ff55 100755 --- a/app/Game/Server/PipeToLobby.js +++ b/app/Game/Channel/PipeToServer.js @@ -1,11 +1,11 @@ define([ "Lib/Utilities/NotificationCenter", - "Game/Server/Channel" + "Game/Channel/Channel" ], function (Nc, Channel) { - function PipeToLobby (process) { + function PipeToServer (process) { var self = this; @@ -28,7 +28,7 @@ function (Nc, Channel) { }); } - PipeToLobby.prototype.send = function (recipient, data) { + PipeToServer.prototype.send = function (recipient, data) { var message = { recipient: recipient, data: data @@ -37,10 +37,10 @@ function (Nc, Channel) { this.process.send(message); }; - PipeToLobby.prototype.onMessage = function (message) { + PipeToServer.prototype.onMessage = function (message) { Nc.trigger(message.recipient + '/controlCommand', message); } - return PipeToLobby; + return PipeToServer; }); \ No newline at end of file diff --git a/app/Game/Server/Player.js b/app/Game/Channel/Player.js similarity index 100% rename from app/Game/Server/Player.js rename to app/Game/Channel/Player.js diff --git a/app/Game/Server/User.js b/app/Game/Channel/User.js similarity index 100% rename from app/Game/Server/User.js rename to app/Game/Channel/User.js diff --git a/app/Lib/Utilities/Extensions.js b/app/Lib/Utilities/Extensions.js index 6af99e1..1f9c032 100755 --- a/app/Lib/Utilities/Extensions.js +++ b/app/Lib/Utilities/Extensions.js @@ -8,7 +8,7 @@ function() { return f + this.substr(1); } - if(GLOBALS.context == "Server") { + if(GLOBALS.context == "Channel") { console.checkpoint = function (s) { console.log(' \033[32mbeep - \033[0m' + s); diff --git a/app/Lib/Utilities/NotificationCenter.js b/app/Lib/Utilities/NotificationCenter.js index 6448de7..578cc6a 100755 --- a/app/Lib/Utilities/NotificationCenter.js +++ b/app/Lib/Utilities/NotificationCenter.js @@ -66,7 +66,7 @@ function () { } }, server: { - pipeToLobby: function(v) { return v + "-ns.server.pipeToLobby")} + pipeToServer: function(v) { return v + "-ns.server.pipeToServer")} }, lobby: { diff --git a/app/Lobby/Api.js b/app/Server/Api.js similarity index 100% rename from app/Lobby/Api.js rename to app/Server/Api.js diff --git a/app/Lobby/Coordinator.js b/app/Server/Coordinator.js similarity index 97% rename from app/Lobby/Coordinator.js rename to app/Server/Coordinator.js index b1d2d60..454afae 100755 --- a/app/Lobby/Coordinator.js +++ b/app/Server/Coordinator.js @@ -1,7 +1,7 @@ define([ - "Lobby/User", - "Game/Server/Channel", - "Lobby/PipeToChannel", + "Server/User", + "Game/Channel/Channel", + "Server/PipeToChannel", "Lib/Utilities/NotificationCenter" ], diff --git a/app/Lobby/PipeToChannel.js b/app/Server/PipeToChannel.js similarity index 100% rename from app/Lobby/PipeToChannel.js rename to app/Server/PipeToChannel.js diff --git a/app/Lobby/User.js b/app/Server/User.js similarity index 100% rename from app/Lobby/User.js rename to app/Server/User.js diff --git a/channel.js b/channel.js index 6d397d8..3294623 100755 --- a/channel.js +++ b/channel.js @@ -1,4 +1,4 @@ -GLOBALS = { context: "Server" }; +GLOBALS = { context: "Channel" }; var requirejs = require('requirejs'); requirejs.config({ @@ -10,11 +10,11 @@ requirejs.config({ var inspector = {}; requirejs([ - "Game/Server/PipeToLobby" + "Game/Channel/PipeToServer" ], -function (PipeToLobby) { - var PipeToLobby = new PipeToLobby(process); +function (PipeToServer) { + var PipeToServer = new PipeToServer(process); - inspector.PipeToLobby = PipeToLobby; + inspector.PipeToServer = PipeToServer; }); \ No newline at end of file diff --git a/server.js b/server.js index 21dd3ef..9d829aa 100755 --- a/server.js +++ b/server.js @@ -1,4 +1,4 @@ -GLOBALS = { context: "Server" }; +GLOBALS = { context: "Channel" }; var requirejs = require('requirejs'); var inspector; @@ -23,7 +23,7 @@ var options = { requirejs([ "Bootstrap/HttpServer", "Bootstrap/Socket", - "Lobby/Coordinator" + "Server/Coordinator" ], function (HttpServer, Socket, Coordinator) {