Node.JS Game Server
This project aim to create an easy to use multiplayer game server. Suitable with HTML5 Websocket, Unity3D, Flash, C++/OpenGL/DirectX, XNA clients,... Programmers onlyhave to implement gameplay logic which will be run in each game room and don't have to care much about the core server. The Core Server is a room-based multiplayer system that enable players connect, chat in Global Lobby, join/create room, chat in rooms.
Usage
You only have to run the server.js to run game server. And write game logic code in room.js
Writing Game Logic
Room Logic will be implemented in run() method of the file: room.js like this:
function run(room, player, msg)
{
// Implement your game room (server side) logic here
console.log("Processing " + player.name + "@" + room.name + ": " + msg);
}
With room: is the current game room. player: is the current player who sending message. msg: is the message sent from player.
Core Server Messages
The list below is the messages defined and used by Core Server. You need this to implement some feature (join room, create room, chat,...) in client-side
-
Player connected to server
RECEIVE: [CONNECTED;] (Everyone except sender)
-
Player disconnected from server
RECEIVE: [DISCONNECTED;] (Everyone except sender)
-
Player send a chat message in Global chat
SEND: [CHAT;] RECEIVE: [CHAT;;] (Everyone in Global lobby)
-
Player created a Room
SEND: [CREATEROOM;;]
-
Player joined room
SEND: [JOINROOM;] RECEIVE: [JOINEDROOM;] (Sender) [JOINROOM;] (Players already in room) [NOROOM;] (Sender - when room not found) [ROOMFULL;] (Sender - when room is full)
-
Player left room
SEND: [LEAVEROOM] RECEIVE: [LEFTROOM;] (Players already in room)
-
Player chat in a room
SEND: [CHATROOM;] RECEIVE: [CHATROOM;;] (Players already in room)
-
Get available room list
SEND: [GETROOMLIST] RECEIVE: [ROOMLIST;] (Sender)