Skip to main content

Overview

Project structure

. # root of the project
├──── node_modules
├──── .rivalis
│ ├ config.json # dev environment configuration
│ ├ console.sqlite # SQLite database file
│ ├ secret.key # private RS256 key used for generating JWT tokens
│ ├ secret.key.pub # public RS256 key used for validating JWT tokens
├──── src
│ ├──── rooms
│ │ ├ MyFirstRoom.js # implementation of the room named "myFirstRoom"
│ ├──── routers
│ │ ├ ChatRouter.js # Simple chat logic
│ ├ index.js # entrypoint, # defines myFirstRoom
├ .gitignore
├ babelrc.json
├ package-lock.json
├ package.json

Terminology

  • Actor - stands for one connected user to the real-time application server. The actor can send and receive messages.
  • Router - Collection of routes where the messages are handled. The idea behind the router is to implement application logic in a way to be reused in multiple rooms/projects.
  • Room - Provides API for sending/broadcasting messages and managing actors.
  • Instance - one runnable instance of rivalis real-time server application. One instance can hold multiple rooms.
  • Registry - Orchestrator used to manage set of rivalis instances.

Development environment

After executing npm start command, @rivalis/cli starts 3 services on your local machine.

  1. Instance - The real-time server that you are developing right now. The entrypoint of the server is src/index.js. By default, the instance is started on 26001 port.
  2. Registry - In your development environment, Registry server is used to provide API for creating/destroying rooms used by the service called "Console".
  3. Console - Web application useful for debugging your real-time server.

Console application can be accessed via browser on http://localhost:2334. Default password is: admin rivalis window