0.1.4 • Published 9 years ago

socket-subscriber v0.1.4

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

socket-subscriber

Demo

demo page

Usage

Create a instance.

var client = new SocketSubscriber(url, {debug:true});

Register connect and error events.

client.on('connect', ()=> console.log('connection')); 
client.on('close', ()=> console.log('close'));

Subscribe a room with register listener.

client.room('type', 'id').on((evt)=> console.log(evt));

Subscribe a date pusher with register listener.

client.date().on((evt)=> console.log(evt));

Send a message to room.

client.sendRoom('type', 'id', data);

Event

  • connect
  • close
  • idle

API

SocketSubscriber(url:string, opts:object?)

opts.debug(boolean): Trace logs. (default:false)

opts.retryCount(Number): The value is retring count. The connection is not retring if value is 0. And value < 0 will retry to connect success. (default: 10000)

opts.retryTime(Number): Retry delay time. (default: -1)

opts.idleTime(Number): Set idle time. (default: 600000)

opts.incomingHeartbeat(Number): Set headrtbeat from server. (default: 1000 ms)

  • on(evtName:string, listener:function)
  • off(evtName:string, listener:function)
  • debug(enabled:boolean)
  • date() : Channel
  • room(type:string, id:string) : Channel
  • exitRoom(type:string ,id: string)
  • sendRoom(type:string, id:string, label:string?, data:object?, headers: object?)
  • getSockJSSessionId():string

Channel

  • on(evtName:string?, listener:function):Channel
  • off(evtName:string?, listener:function):Channel

Run dev

npm run dev

Build

npm run build
0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago