-
Notifications
You must be signed in to change notification settings - Fork 21
Draft: Next version
Marcel Klehr edited this page Jun 2, 2014
·
5 revisions
Note: This is the draft of the next version of smokesignal. Feel free to leave comments along with your username
smoke.createNode
- config: myAddress
- config: seeds #a known node, that's part of the network
Node
- addPeer(address:port, cb(er, peer))
- events: connect, disconnect, error, new peer
- peers[]
Peer < DuplexStream
- events: disconnect, error
Middleware? provide a Constructor of a DuplexStream (or rather a factory function?). Middleware streams are stacked on top of each other, above the DATA channel of the peer link. Perhaps send a list of applied middleware along with HANDSHAKE.
- PGP? (mh. tls at a lower would prolly be better)
- ...?
I don't know if middleware is at all useful.
Plugins can define and intercept custom messages and extend Node.prototype.
- Broadcast
- Ping/Autoping
- Friendly (takes :desiredPeerCount)
HANDSHAKE
- read "would you like to be peers with me?"
SHAKEHAND
- read "yep, I very much would like to be peers with you."
DATA
- read "this is something I'd like you to know"
- a and b are unconnected
- a connects to b
- a and b are connected
- a sends HANDSHAKE to b
- b end SHAKEHAND a
- a and b are peers
- a and b are peers
- a sends DATA to b
BROADCAST
- read "I want you and everyone else to know this."
PING
- read "Would you mind pass this around to everyone, until it reaches X? If you're X then please call me back."
PONG
- read "Hey there, someone said I should call you?!"
NEEDFRIEND
- read "Please tell everyone that they can shake my hand at X."
COUNT
- read "Give this message to all your peers, unless you've got this already. If so, just return 1 to me with COUNTED. If not, sum the counts of your friends +1 and tell me the result with COUNTED."
COUNTED
- read "I counted X."