Coder Social home page Coder Social logo

moqi / node-js-game-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from huytd/node-js-game-server

0.0 2.0 0.0 128 KB

Easy to use Multiplayer Game Server based on Node.JS. Suitable with HTML5 Websocket, Unity3D (Web/PC, Android, iOS,...), Flash, C++/OpenGL/DirectX, XNA clients,...

node-js-game-server's Introduction

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

  1. Player connected to server

    RECEIVE: [CONNECTED;] (Everyone except sender)

  2. Player disconnected from server

    RECEIVE: [DISCONNECTED;] (Everyone except sender)

  3. Player send a chat message in Global chat

    SEND: [CHAT;] RECEIVE: [CHAT;;] (Everyone in Global lobby)

  4. Player created a Room

    SEND: [CREATEROOM;;]

  5. 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)

  6. Player left room

    SEND: [LEAVEROOM] RECEIVE: [LEFTROOM;] (Players already in room)

  7. Player chat in a room

    SEND: [CHATROOM;] RECEIVE: [CHATROOM;;] (Players already in room)

  8. Get available room list

    SEND: [GETROOMLIST] RECEIVE: [ROOMLIST;] (Sender)

node-js-game-server's People

Contributors

huytd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.