0.0.1 • Published 6 years ago

localhosted v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Localhosted JS

The JS client for Localhosted

Installation

Using npm:

npm install localhosted

Using yarn:

yarn add localhosted

Usage

import Localhosted from 'localhosted';

let localhosted = new Localhosted();

// subscribe a function to "chat" events from the server
localhosted.subscribe('chat', (data, reply) => {
  console.log(data);
  rely({'replying': 'this object is sent back to the server as a "chat" event'})
})

localhosted.emit('clientEvent', {'creator': 'the client created this event'})

// With callbacks on socket connect and on close
let localhosted = new Localhosted(
  (evt) => {
    console.log('Connected to socket:', evt)
  },
  (evt) => {
    console.log('Disconnected from socket:', evt)
  });