0.1.3 • Published 8 years ago

@splytech-io/splyt-ws-message-handler v0.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
8 years ago

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));

});
0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago