socket-envelope

1.0.5 • Public • Published

SocketEnvelope

Overview

SocketEnvelope is a React component implementation of the WebSocket protocol. Unlike a lot of other implementations, SocketEnvelope actually allows for sending messages to the server, not just reading messages.

Installation

yarn add socket-envelope

Usage

import { SocketEnvelope } from 'socket-envelope';

<SocketEnvelope url={url}
                envelope={envelope}
                onMessage={this.onMessage}
                formatEnvelope={this.formatEnvelope} />
attr type
url string
envelope object
onMessage func
formatEnvelope func

The way SocketEnvelope determines if it should send a message is by comparing the timestamp property on envelope.

The onMessage handler will receive the message event, the payload of which is accessible with event.data.

The formatEnvelope handler will receive the envelope object and should return either a string or binary message.

Readme

Keywords

Package Sidebar

Install

npm i socket-envelope

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

8.1 kB

Total Files

7

Last publish

Collaborators

  • serra-allgood