1.0.2 • Published 4 years ago

soba-be v1.0.2

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
4 years ago

Soba - Backend

npm version

Soba is a simple React-based web game engine. By using higher-order components, Soba manages the generic socket.io messages and injecting additional functions as props. Integrating with Soba allows web games to be made more lightweight.

This is a library function for the Node backend contrasting the React front-end using Soba.

For more information regarding game design and how Soba works, see the main repository.

Applications using Soba

There is a starting example in this repository to start off with.

The following are other projects that use Soba.

  1. Articulate

Dependency

  1. socket.io
$ npm install --save socket.io

Installation and Quickstart

  1. Install the npm module in your NodeJS backend server project root directory

    $ npm install --save zhenghung/soba-be
  2. Import the function and use it in your io.on callback. An example template index.js file is as follows:

    This requires a few dependencies which can be installed with this

    $ npm install --save http express socket.io cors

    index.js

    const http = require('http');
    const express = require('express');
    const socketio = require('socket.io');
    const cors = require('cors');
    const soba = require('soba-be');
     
    const app = express();
    const server = http.createServer(app);
    const io = socketio(server);
    
    app.use(cors());
    app.use(express.json());
    
    io.on('connect', (socket) => {
        soba(io, socket, {logging: true});
    
        /** Add more socket.on listener handlers here*/
    });
    
    server.listen(process.env.PORT || 5000,() => console.log(`Server has started.`));

Configuration

Custom configuration can be tweaked as it it passed as the third argument into the function. soba(io, socket, config)

Default configurations

{
    logging: false
}
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago