Provides easy and secure websocket communication mechanisms, including server and client implementation, function call routing, connection management, and tagging.
Go to file
2016-08-07 19:07:24 +02:00
dist now tests run trough 2016-08-07 18:59:39 +02:00
test now tests run trough 2016-08-07 18:59:39 +02:00
ts now tests run trough 2016-08-07 18:59:39 +02:00
.gitignore update structure 2016-08-07 14:58:20 +02:00
.gitlab-ci.yml initial 2016-08-06 23:27:53 +02:00
package.json 1.0.3 2016-08-07 19:07:24 +02:00
README.md improve README 2016-08-07 19:07:11 +02:00

smartsocket

easy and secure websocket communication, Typescript ready

Status

build status

Usage

We recommend the use of typescript. Under the hood we use socket.io and shortid for managed data exchange.

Serverside

import * as smartsocket from "smartsocket";

let mySmartsocket = new smartsocket.Smartsocket({
    port: 3000 // the port smartsocket will listen on
});

let mySocketRole = new smartsocket.SocketRole({
    name: "someRoleName",
    passwordHash: "someHashedString"
});

let mySocketFunction = new smartsocket.SocketFunction({
    name:"newService",
    func:(data) => {
        
    }, the function to execute
    roles:[mySocketRole] // all roles that have access to a specific function
});

mySmartsocket.registerRole(mySocketRole);
mySmartsocket.clientCall.select("client1","restart",data)
    .then((responseData) => {

    });

Client side

import * as smartsocket from "smartsocket";

let mySmartsocketClient = new smartsocket.SmartsocketClient({
    url: "somedomain.com", // url, note: will only work over https, no http supported.
    port: 3000
    role:"dockerhost", // some role, in this example a dockerhost vm,
    password:"somePassword",
    alias:"client1"
});

let mySocketFunction2 = new smartsocket.SocketFunction({
    name:"restart",
    func:(data) => {}, the function to execute
});

mySmartsocketClient.registerFunction(mySocketFunction2);

mySmartsocketClient.serverCall("newService",data)
    .then((responseData) => {
        
    });;

NOTE: you can easily chain dependent requests on eiter the server or client side with promises. data is always a js object that you can design for your specific. It supports buffers for large binary data network exchange.