socket.io-server

A simple bootstrap project for creating node.js servers with socket.io

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
socket.io-server
1.0.0-b5 years ago5 years agoMinified + gzip package size for socket.io-server in KB

Readme

Socket.IO Server
A simple bootstrap project for creating node.js servers with socket.io

Setup

In the following a simple bootstrap script to setup your server. For a detailed example follow the content in example.js
./index.js
import {App} from 'socket.io-server'

import TestCommand from './src/Commands/TestCommand'

let app = new App({
    port: 8303, // The port the server shoud listen to
    commands: [
        TestCommand
    ]
});

app.run();
./src/Commands/TestCommand.js
import {BaseCommand} from 'socket.io-server'

export default class TestCommand extends BaseCommand 
{
    initialize()
    {
        this.name = 'test';
    }
    
    execute()
    {
        console.log('test executed')
    }
}

If you take a look at the base command you can see that you have access to the following objects:
export default class BaseCommand
{
    constructor(app, client)
    {
        this.app    = app;    // The app instance it self
        this.client = client; // A personalized instance of the client
        this.name   = null;   // The name of the command which is required to execute the command
        
        this.initialize();
    }
}