sawk

0.0.2 • Public • Published

Sawk Build Status

A tiny and resilient websocket client for the browser

Installation

npm install sawk --save

Usage example

Sawk provides basic utilities wrapped around the native WebSocket interface. If messages are sent before the connection is open, Sawk will queue those messages to be sent on the open event. Sawk also provides a reconnect function which when combined with the onClose handler, allows you to reconnect a closed connection.

import sawk from 'sawk';
 
const socket = new Sawk('wss://echo.websocket.org/')
 
socket.onMessage = (event) => {
};
 
socket.onError = (event) => {
};
 
socket.onClose = (event) => {
  socket.reconnect();
}
 
socket.send('a message');
 

Development setup

npm install
npm test
npm build

Meta

Ryan Hinchey – @ryhinchey

Distributed under the MIT license. See LICENSE.txt for more information.

https://github.com/ryhinchey/sawk

Contributing

  1. Fork it (https://github.com/rhinchey/sawk/fork)
  2. Create your feature branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -am 'Add a new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Create a new Pull Request

Readme

Keywords

none

Package Sidebar

Install

npm i sawk

Weekly Downloads

6

Version

0.0.2

License

MIT

Unpacked Size

4.95 kB

Total Files

4

Last publish

Collaborators

  • ryhinchey