Skip to content

Instantly share code, notes, and snippets.

@pantlesswonder
Created November 26, 2012 23:53
Show Gist options
  • Save pantlesswonder/4151451 to your computer and use it in GitHub Desktop.
Save pantlesswonder/4151451 to your computer and use it in GitHub Desktop.
plug rpc
//send just calls JSON.stringify and then client.write using that string
//respond to a ping
state.client.send({
type: 'rpc', id: 2,
name: 'user.pong', args: []});
//join a room
state.client.send({
type: 'rpc', id: 1,
name: 'room.join', args: [room]});
//woot a song (first args parameter is true for woot, false for meh)
state.client.send({type: 'rpc', id: 4,
name: 'room.cast', args: [true, state.data.room.historyID, true]});
You need to have a new id for every RPC call, can't use static ones.
Socket will respond to every rpc call, so you'll want some callback system based on ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment