2.0.17 • Published 4 years ago

socommujs v2.0.17

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

SocommuJS SocketCommunication

Christoph Ehlers 19/20

  • Plugin based Websocket-Server
  • Websocket-Client
! work in progress !
  • Complete documentation
    • Installation
    • Basic Usage
      • Server
      • Client
    • Create Serverplugin
    • Create Authenticationplugin

Install

npm install socommujs

Using Socommujs

Server

Basic Example

import Server from "socommujs/dist/Server";

const port = 2607; // this is the default port
const myServer = new Server();

myServer.listen(port);

Using Plugins

import Server from "socommujs/dist/Server";    
import AuthPlugin from "socommujs/dist/serverplugin/AuthPlugin";

const myServer = new Server();

myServer.addPlugin(new AuthPlugin());
myServer.listen();

Client

API

Server

  • addEventListener(event, properties)
  • addPlugin(plugin)
  • Eventhandler
  • getPort()
  • getState()
  • HttpServer
  • listen(port)
  • plugins
  • setPort(port)
  • WebsocketServer

Client

  • connect
  • send
  • sendRequest
  • on
  • Socket

Events

Serverevents

  • clientConnected
  • clientDisconnected
  • clientWillConnect
  • getAuthenticatedRequest
  • getClientRequest
  • getUnauthenticatedRequest
  • log
  • serverInitialized
  • serverStart
  • serverStop
Example listen Serverevent directly

Example 1 (using eventname):

import Server from "socommujs/dist/Server";

const myServer = new Server();

myServer.addEventListener('serverStart',()=>{
    // do something
});

Example 2 (using EServerEvent-Enum):

import Server from "socommujs/dist/Server";
import {EServerEvent} from "socommujs/dist/lib/enums";

const myServer = new Server();

myServer.addEventListener(EServerEvent.serverStart,()=>{
    // do something
});

To see how to use Serverplugins to handle Serverevents click here.

2.0.17

4 years ago

2.0.16

4 years ago

2.0.15

4 years ago

2.0.14

4 years ago

2.0.13

4 years ago

2.0.11

4 years ago

2.0.12

4 years ago

2.0.9

4 years ago

2.0.10

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.5

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago