1.3.0 • Published 9 years ago

wsabi-client v1.3.0

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

Wsabi Client

A lightweight client for the hapi websocket layer, wsabi.

This aims to be lightweight and avoids using large libraries such as sails.io.js and socket.io-client. The footprint is currently 4.8 kB minified and gzipped.

Usage

import {WsabiClient} from "wsabi-client";

// You can set the promise and websocket libraries the client will use.
// This is useful in environments that either don't support Promises, or
// environments such as NodeJS that don't provide a default WebSocket implementation.
WsabiClient.WebSocket = require("ws");
WsabiClient.Promise = require("bluebird");

let wsabi = new WsabiClient("wss://localhost:3000");

// Set the live endpoint. Defaults to '/live'
wsabi.liveUrl = "/v1/live";
  
// Send requests to the server with get, put, post, delete, or request.
wsabi.get("/v1/user/current").then((res) => {
  // Subscribe to a live event
  let updateSub = wsabi.live(`user:${res.id}:update`).subscribe(
    update => console.log("User update!", update),
    err => console.error("There was an error subscribing", err)
  )
  
  // ...
  
  updateSub.unsubscribe();
});
1.3.0

9 years ago

1.2.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago