Git Product home page Git Product logo

gamehub.io's Introduction

About GameHub.io

![Gitter](https://badges.gitter.im/Join Chat.svg)

GameHub.io is an attempt to make a real-time multi player gaming server using the following technologies:

Client side

Server side

Goals

The main goal of GameHub.io is to provide a non trivial web application serving as an example of gaming server using the aforementioned technologies.

Here is a list of core features:

  • Application structure and setup
  • User authentication and registration process (/login & /register)
  • Real time multi player gaming logic (See gaming logic section)
  • RESTful API (/api)
  • Real time monitoring dashboard (/monitor)
  • "TV" page to broadcast any real time content (/tv)
  • Real time game indexing and searching using ElasticSearch (/search)

Gaming logic

GameHub.io uses a simple gaming sequence through Socket.io that works for 2+ players. Here is a simplified diagram of most relevant events:

gamehub.io

  1. Each player can create a game by sending a 'create-game' event to the server
  2. The server creates a new game and replies to the player with a randomly generated token for the game
  3. The player sends this token to other players and waits for them to join the game
  4. Others players join the game by sending a 'join-game' event to the server
  5. Once all players joined the game, the server joins players sockets to the same socket.io room
  6. At this point, the game starts: depending on the game nature, each player can send a random number of events that will be broadcast to other players.
  7. When the game is over, each player is notified and sockets leave the game room

Use case: ChessHub.io

Introduction

ChessHub.io is a real time multi player chess server that serves as a sample of how to reuse GameHub.io core features.

The goal of ChessHub.io is not to provide a fully featured web application to play chess online.

Even though the application is related to chess, it is easy to change the domain model along with application logic and keep/adapt the application structure.

Why Chess?

  • Because it is a good use case for real time multi player gaming
  • Because every time you look for a real time application example on the web, you end up on chat applications, so I decided to change the landscape :-)
  • Because I am a chess junkie!

Credits

Chess logic on the client side uses the excellent Chess.js and Chessboard.js libraries.

Live demo

http://chesshub-benas.rhcloud.com/

Build and Run the application

Prerequisites

  • Node JS
  • Mongo DB up and running on the default port (27017) and using the default database (test)
  • ElasticSearch server up and running on the default port (9200)

Run the application

$> npm install
$> node initData.js
$> node .

Browse the following address: http://localhost:3000

You can register a new account or sign in with the following credentials: [email protected] / foobar

Note: The initData.js script will populate Mongo DB and ElasticSearch with some data so you can use the application.

Screen shots

Home page

home

Playing chess in real time

play

Watch live game

tv

Search a game

search

Real time monitoring dashboard

monitor

Contribution

There are probably some points of improvement in the application design, structure or code.

If you believe there is a best practice I have not followed, please let me know by opening an issue on the issue tracker. Pull requests are welcome!

License

GameHub.io is released under the MIT license (see LICENSE file).

gamehub.io's People

Contributors

gitter-badger avatar

Watchers

James Cloos avatar Zhenyu Hou 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.