Giter VIP home page Giter VIP logo

rivalis-core's Introduction

Rivalis Core

logo

forthebadge forthebadge forthebadge forthebadge

GitHub Build Status GitHub Release) npm downloads Read docs Visit website Discord


Rivalis is open source framework for building multiplayer game servers.

  • Extensible - Rivalis can work with multiple protocols at same time.
  • Scalable - Rivalis provides interfaces for integration with any external databases and services
  • Easy to use - Rivalis provides extensible & well designed API, read more about that in the documentation

Getting Started

Prerequisites

  • JavaScript & NodeJS knowledge
  • NodeJS (v12.0 or higher) installed on your local machine
  • Code Editor

New Project

  • Create empty npm project using npm init in empty directory
  • Install rivalis-core library using npm i --save @rivalis/core
  • Install rivalis websocket protocol library using npm i --save @rivalis/protocol-websocket
  • Create simple entrypoint for your project like:

server.js

const http = require('http')
const { Node, AuthResolver } = require('@rivalis/core')
const { WebSocketProtocol } = require('@rivalis/protocol-websocket')

// http server is used only for websocket protocol
const server = http.createServer()

// AuthResolver is the place where you need to implement your authentication/authorization logic.
class CustomAuthLogic extends AuthResolver {
    async onAuth(ticket, node) {
        // --- EXAMPLE (IMPLEMENT YOUR LOGIC HERE) ---
        let { roomId, actorId, data } = this.getFromTicket(ticket)
        let room = await node.rooms.obtain(roomId)
        return room.actors.join(actorId, data)
    }
}

const webSocketProtocol = new WebSocketProtocol({ server })
const rivalis = new Node({
    transports: [ webSocketProtocol ]
})
rivalis.run()
server.listen(2345)

Follow the official documentation.

Let's begin with hacking!

License

The project is licensed under MIT License

rivalis-core's People

Contributors

kalevski avatar

Watchers

James Cloos 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.