express-socket
## Server
Last updated a year ago by playerone .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install express-socket 
SYNC missed versions from official npm registry.

Express Socket (TLS / TCP)

Server

const path = require('path);
const constants = require(path.join(__dirname, 'constants'))

const ExpressSocket = require('express-socket/api');

const socket = new ExpressSocket();

const networkHost = 'localhost';
const retryTimeInMS = 1500;

const serverPubKey = path.join(__dirname, 'server.pub');
const serverKey = path.join(__dirname, 'private/server.key');
const param = path.join(__dirname, 'dhparam.pem');
const requestCert = true;
const rejectUnauthorized = true;
const requestCert = true;

const clientPubs = [];

// Create client pub here

clientPubs.push(client.pub);

const config = {
    retry: retryTimeInMS,
    networkHost: networkHost
    tls: {
        public: serverPubKey,
        private: serverKey,
        dhparam: param,
        requestCert: requestCert,
        rejectUnauthorized: rejectUnauthorized,
        trustedConnections: clientPubs
    }
};

socket.setConfig(config)

socket.queue('onSomeEvent_One', (data)  = > {
    console.log(data)
    socket.send('someOtherEvent_Four', {
        some: "Data"
    })
})

socket.queue('onSomeEvent_Two', (data)  = > {
    console.log(data)
    socket.send('someOtherEvent_Five', {
        some: "Data"
    })
})

socket.queue('onSomeEvent_Three', (data)  = > {
    console.log(data)
    socket.send('someOtherEvent_Six', {
        some: "Data"
    })
})

socket.serve('channel_name', function() {

    // Only able to send data in here

    socket.send('someOtherEvent_Six', {
        some: "Data"
    })
});

Client

const ExpressSocket = require('express-socket/web');

const socket = new ExpressSocket();

const clientPub = path.join(__dirname, 'client.pub');
const clientKey = path.join(__dirname, 'client.key');
const retryTimeInMS = 1500;
const networkHost = 'localhost';
const rejectUnauthorized = true;
const serverPubs = [];

// add server pub here

serverPubs.push(server.pub);

socket.setConfig({
    retry: retryTimeInMS,
    networkHost: networkHost
    tls: {
        public: clientPub,
        private: clientKey,
        rejectUnauthorized: rejectUnauthorized,
        trustedConnections: serverPubs
    }
})

socket.queue('onSomeEvent_One', (data)  = > {
    console.log(data)
    socket.send('someOtherEvent_Four', {
        some: "Data"
    })
})

socket.queue('onSomeEvent_Two', (data)  = > {
    console.log(data)
    socket.send('someOtherEvent_Five', {
        some: "Data"
    })
})

socket.queue('onSomeEvent_Three', (data)  = > {
    console.log(data)
    socket.send('someOtherEvent_Six', {
        some: "Data"
    })
})

socket.connect('channel_name', function() {

    // Only able to send data in here

    socket.send('someOtherEvent_Six', {
        some: "Data"
    })
});

Current Tags

  • 1.0.38                                ...           latest (a year ago)

21 Versions

  • 1.0.38                                ...           a year ago
  • 1.0.30                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.26                                ...           a year ago
  • 1.0.25                                ...           a year ago
  • 1.0.24                                ...           a year ago
  • 1.0.23                                ...           a year ago
  • 1.0.22                                ...           a year ago
  • 1.0.21                                ...           a year ago
  • 1.0.20                                ...           a year ago
  • 1.0.19                                ...           a year ago
  • 1.0.18                                ...           a year ago
  • 1.0.17                                ...           a year ago
  • 1.0.16                                ...           a year ago
  • 1.0.15                                ...           a year ago
  • 1.0.14                                ...           a year ago
  • 1.0.13                                ...           a year ago
  • 1.0.12                                ...           a year ago
  • 1.0.11                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |