All Projects → udamir → magx

udamir / magx

Licence: MIT license
Multiplayer game server framework

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to magx

Colyseus
⚔ Multiplayer Framework for Node.js
Stars: ✭ 3,817 (+11126.47%)
Mutual labels:  multiplayer, game-server, multiplayer-game-server
Nakama
Distributed server for social and realtime games and apps.
Stars: ✭ 5,293 (+15467.65%)
Mutual labels:  multiplayer, game-server
haskell-tic-tac-toe
A multiplayer web real-time implementation of the famous Tic Tac Toe game in Haskell.
Stars: ✭ 51 (+50%)
Mutual labels:  multiplayer, game-server
Gameproject3
游戏服务器框架,网络层分别用SocketAPI、Boost Asio、Libuv三种方式实现, 框架内使用共享内存,无锁队列,对象池,内存池来提高服务器性能。还包含一个不断完善的Unity 3D客户端,客户端含大量完整资源,坐骑,宠物,伙伴,装备, 这些均己实现上阵和穿戴, 并可进入副本战斗,多人玩法也己实现, 持续开发中。
Stars: ✭ 655 (+1826.47%)
Mutual labels:  multiplayer, game-server
LunarGdx
A networking library for LibGDX utilizing Netty allowing easy creation of multiplayer games.
Stars: ✭ 23 (-32.35%)
Mutual labels:  multiplayer, multiplayer-game-server
Ogar3
A better version of Ogar
Stars: ✭ 22 (-35.29%)
Mutual labels:  multiplayer, multiplayer-game-server
Crystalshire
Legacy VB6 open-source ORPG
Stars: ✭ 24 (-29.41%)
Mutual labels:  multiplayer, game-server
basic multiplayer unity
UDP Client-Server implementation in Unity
Stars: ✭ 44 (+29.41%)
Mutual labels:  multiplayer, game-server
Kaetram Open
An open-source 2D HTML5 adventure based off BrowserQuest (BQ).
Stars: ✭ 138 (+305.88%)
Mutual labels:  multiplayer, game-server
Lance
Multiplayer game server based on Node.JS
Stars: ✭ 1,161 (+3314.71%)
Mutual labels:  multiplayer, game-server
Linuxgsm
The command-line tool for quick, simple deployment and management of Linux dedicated game servers.
Stars: ✭ 3,063 (+8908.82%)
Mutual labels:  game-server, multiplayer-game-server
Segs
💪 SEGS - Super Entity Game Server
Stars: ✭ 190 (+458.82%)
Mutual labels:  multiplayer, game-server
Agones
Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes
Stars: ✭ 4,252 (+12405.88%)
Mutual labels:  multiplayer, game-server
Gophergameserver
🏆 Feature packed, easy-to-use game server API for Go back-ends and Javascript clients. Tutorials and examples included!
Stars: ✭ 61 (+79.41%)
Mutual labels:  multiplayer, game-server
Rhubarb
A WebSocket library optimized for multiplayer JS games, works on WebWorkers with binary data.
Stars: ✭ 167 (+391.18%)
Mutual labels:  multiplayer, game-server
colyseus-kotlin
⚔ Implementation of Colyseus client using Kotlin
Stars: ✭ 26 (-23.53%)
Mutual labels:  multiplayer, game-server
Steam-Server-Manager
PowerShell Steam Server Manager
Stars: ✭ 33 (-2.94%)
Mutual labels:  game-server
ctf-gameserver
FAUST Gameserver for attack-defense CTFs
Stars: ✭ 38 (+11.76%)
Mutual labels:  game-server
TanksNetworkingInAzure
Tanks Networking demo project from Unity Store that can be deployed in Azure Cloud and scaled using Kubernetes
Stars: ✭ 20 (-41.18%)
Mutual labels:  game-server
SparkServer
SparkServer是一个参照skynet设计的C#服务端框架,能够无缝整合到skynet集群机制中,也能自行组网,构建只有SparkServer节点的集群
Stars: ✭ 184 (+441.18%)
Mutual labels:  game-server

MagX

npm npm npm type definitions GitHub

Multiplayer Game Server Framework for Node.js

What is MagX?

Magx is a Multiplayer Game Server Framework for Node.js: server-authoritative multiplayer approach is supported as well as relayed multiplayer (also known as client-authoritative).

In server-authoritative multiplayer approach room state maintained on the server and clients are just visual representations of the current game state. Each client can send messages to change room state, these messages can be validated by server and state changes broadcast to room clients. This enables you to build:

  1. Asynchronous real-time authoritiative multiplayer: Fast paced realtime multiplayer. Messages are sent to the server, server calculates changes to the environment and players and data is broadcasted to relevant peers. This typically requires a high tick-rate for the gameplay to feel responsive.

  2. Active turn-based multiplayer: Like with Stormbound or Clash Royale mobile games where two or more players are connected and are playing a quick turn-based match. Players are expected to respond to turns immediately. The server receives input, validates them and broadcast to players. The expected tick-rate is quite low as rate of message sent and received is low.

To create Authoritative Multiplayer server you need Flexible State Mangement with change tracking functionality. MosX is default state managment engine, but you have the freedom and flexibility to choose state managment engine without limitations.

In relayed multiplayer approach each client is act as the host of reconcile state changes between peers and perform arbitration on ambiguous or malicious messages sent from bad clients. So each client sends all state changes to server and server broadcasted them to otherr clients without inspection. This approach can be very useful for many types of gameplay but may not suitable for gameplay which depends on central state managed by the game server.

Summary

MagX provides to you:

  • WebSocket-based communication
  • Simple API in the server-side and client-side.
  • Automatic state synchronization between server and client.
  • Scale vertically or horizontally
  • Fully customizable

Getting started

From examples project

The easiest way to try out MagX is using the magx-example project:

Installation

git clone https://github.com/udamir/magx.git
cd magx/examples
npm install

To run the MagX server, run npm start

Build basic Chat server from scratch

  1. Install magx package:
npm install --save magx
  1. Create a simple chat room handler (chatRoom.ts):
import { Room, Client } from "magx"

export class ChatRoom extends Room {

  public onMessage(client: Client, type: string, data: any) {
    console.log("ChatRoom received message from", client.id, ":", data)
    this.broadcast("messages", `(${client.id}) ${data}`)
  }
  
  public onJoin(client: Client) {
    this.broadcast("messages", `${ client.id } joined.`)
  }
  
  public onLeave(client: Client) {
    this.broadcast("messages", `${ client.id } left.`)
  }
  
  public onClose() {
    console.log("ChatRoom closed!")
  }
}
  1. Create MagX server and define chatRoom (index.ts):
import * as http from "http"
import { Server } from "magx"
import { ChatRoom } from "./chatRoom"

const server = http.createServer()

const magx = new Server(server)
magx.define("chat", ChatRoom)

const port = process.env.PORT || 3001
server.listen(port, () => {
  console.log(`Magx server started on http://localhost:${port}`)
})

Chat server is ready!

  1. Create basic index.html page and attach magx-client:
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width" />

    <!-- magx client -->
    <script type="text/javascript" src="/magx"></script>

  </head>
  <body>
    <strong>Messages</strong><br>

    <form id="form">
      <input type="text" id="input" value="" autofocus/>
      <input type="submit" value="send" />
    </form>

    <div id="messages"></div>

    <script>
      // add js code here
    </script>
  </body>
</html>
  1. Connect to MagX server, authenticate and join ChatRoom:
const { host, port, protocol } = window.document.location
var client = new MagX.Client({ address: host.replace(/:.*/, ''), port, secure: protocol === "https:" })

client.authenticate()
  .then(() => client.getRooms("chat"))
  .then(rooms => rooms.length ? client.joinRoom(rooms[0].id) : client.createRoom("chat"))
  .then(room => {
    console.log("joined")
    
    // listen to messages coming from the server
    room.onMessage("messages", (message) => {
      var p = document.createElement("p");
      p.innerText = message;
      document.querySelector("#messages").appendChild(p);
    })
    
    // send message to room on submit
    document.querySelector("#form").onsubmit = function(e) {
      e.preventDefault();
      var input = document.querySelector("#input");
      console.log("input:", input.value);
      
      // send data to room
      room.send("message", input.value);
      
      // clear input
      input.value = "";
    }
  })

Simple chat is ready! You can open several tabs, send and recieve messags.

Documentation

soon...

Status and roadmap

Current project status

When will Magx v1.0 release

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].