citron-server
v0.2.1
Published
Citron is a low level abstraction layer for a scalable multiplayer game server.
Downloads
5
Maintainers
Readme
citron
Citron is a low-level game server framework. Citron abstracts the networking layer, and makes creating server-side game logic much easier.
Table of contents
TODO
- [ ] Start on testing scripts.
- [x] Connection and data transfer management
- [x] Handle incoming connections
- [x] fire receive event and pass data object (returned from the function on the next bullet).
- [x] Modular (strategy?) pattern for using different data interchange methods. (instead of JSON, use some other more compressed interchange language.) See: STRATEGIES
- [x] Players
- [x] Create new player in limbo instance on connect.
- [x] Custom player events
- [ ] Entities
- [x] Instances
- [x] Default instance events, like on.('enter').
- [ ] Instance options, like 'sendEntityDataOnEnter
- [ ] Store collection of Entities
- [x] Decide whether or not Instances should store a collection of Players.
- [ ] Interactions
- [ ] Callback system?
- [ ] Load Balancing & Clustering
- [ ] SSL
- [ ] Redis
- [ ] Get some proper documentation in here.
Directory Structure
/lib/modules
contains the non-citron logic, like redis./lib/components
contains the main logic for citron.
Framework
- Citron has 4 main components:
- Instances
- Entities
- Interactions
- Players
Instances
isolate players, instances, and entities. Instances define where in the game flow that players and entities can interact with eachother.- Examples:
- Chat Lobbies
- Game lobbies
- World zones
- Battle instances
- Anything you can think of! We give you the tools to manage these instances, but it's up to the logic of your game to determine the level of isolation or how entities and players interact in them.
- Examples:
Entities
define anything
that exists in the game which is intended to be universal for an instance. They are non-playable things which may have interactions. Depending on your game these may not be used, however that is unlikely.- Example:
- Assets
- NPCs
- Example:
Players
is a pretty self-explanatory element. It represents active connections and manages events for those connections.- Lastly,
interactions
define behaviors between players and entities.Interactions
are an abstract. Their meaning depends on your implementation. In general,interactions
will define the AI and logic. If a player, for example, sends an actionattack
with the parameterstarget
andspell
, theinteraction
defined in the server will process it according to the implementation of theattack interaction
. For more information about implementing interactions into your server, see this document. It has examples!
Other information
- We recommend using Redis with Citron, and provide an easy way to do this!
Getting Started
Follow these steps to get started:
- Install Redis. We recommend using Docker to install Redis. Docker isolates Redis and its dependencies on your filesystem as a container.
$ docker pull redis
$ docker run --name my-redis-server -d redis
If you don't want to use Docker, then use your package manager to install Redis.
- On Arch Linux:
$ pacman -S redis
. By default, Redis will not be enabled onsystemd
. To start redis, type$ systemctl start redis
. If you want Redis to start when your computer starts, type$ systemctl enable redis
. - On Debian based distributions, like Ubuntu:
$ apt-get install redis
. - On RHEL based distributions, like Fedora or CentOS:
$ yum install redis
.
If you want to use a different system for managing the data in your game, see this document. Currently citron only supports redis, but PostgreSQL, mongodb, and MariaDB (MySQL).
Add
citron-server
to yourdependencies
inpackage.json
and runnpm install
Start programming. Here is the most basic example of starting a Citron-based server:
This example will start listening on the default citron port, 9981
, connect to the redis server on localhost:6379
.
New connections will be added to the redis user collection, on the default instance limbo
.
var citron = require('citron-server');
cintron.start();
Full Game server example
For an example of a full game server, see the Summoner's Game Server
License
The MIT License (MIT)
Copyright (c) 2016 Kevin Minehart
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.