Created
November 26, 2012 23:53
-
-
Save pantlesswonder/4151451 to your computer and use it in GitHub Desktop.
plug rpc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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