@splytech-io/splyt-ws-message-handler
Splyt WebScoket Message Handler
Last updated a year ago by rainder .
ISC · Repository · Bugs · Original npm · Tarball
$ cnpm install @splytech-io/splyt-ws-message-handler 
SYNC missed versions from official npm registry.

Splyt WebSocket Message Handler

Implementation example

'use strict';

const WebSocket = require('ws');
const SplytWSMessageHandler = require('@splytech-io/splyt-ws-message-handler');

//create websocket connection
const ws = new WebSocket(...);
const handler = new SplytWSMessageHandler();

ws.on('connect', (socket) => {

  socket.on('message', (message) => {
    //handle incoming push/request/response messages from the server
    handler.incoming({
      socket: socket,
      incoming: new SplytWSMessageHandler.Incoming(message),
    }).catch((err) => console.error(err));
  });

  //send push/request/response to the client
  handler.outgoing({
    socket,
    outgoing: new SplytWSMessageHandler.Outgoing({
      type: 'request',
      method: 'passenger.config',
    }),
  }).then((result) => console.log(result));

});
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 25
Last Day 1
Last Week 1
Last Month 16
Dependencies (5)
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |