README
Brokr
brokr is a javascript RPC+PUB/SUB via Websocket library that you shouldn't use.
Usage
In the browser
If you need to use Brokr in the browser, you can
- Use the included connect middleware
Brokr.middleware(url)
to serve a browser friendly Brokr version. - Use the
Brokr.browserify(callback)
function to get the source as a string. - Use the included build tool. Simply run
make build
in the Brokr module root to build thebrokr.web.js
file.
Brokr spec.
very much work in progress
brokr
v : version 1.0
t : type hey, req, res, pub, sub, unsub, pserr,
p : package data. Format depends on type field
Meta
"Hey" package
{
"brokr": {
"v": "1.0",
"t": "hey",
"p": {
}
}
}
RPC
request package containing 2 requests
{
"brokr": {
"v": "1.0",
"t": "req",
"p": {
"abcd1": {
"fn": "ping",
"args": []
},
"abcd2": {
"fn": "time",
"args": []
},
}
}
}
response package containing 2 responses
{
"brokr": {
"v": "1.0",
"t": "res",
"p": {
"abcd2": [null, "pong"], //[error, data]
"abcd1": [null, 1370981044.033] //[error, data]
}
}
}
PubSub
- Topics must be created on the fly.
- There is no queue
subscribe package
{
"brokr": {
"v": "1.0",
"t": "sub",
"p": {
"abcd1": {
"topic": "notifications"
},
"abcd2": {
"topic": "new-topic"
}
}
}
}
subscribe OK/err
Response to each subscription request.
null
means no error.
Errors codes are: (WIP)
010 That is already the case
100 Generic client error
101 Not a subscriber
200 Generic server error
{
"brokr": {
"v": "1.0",
"t": "pserr",
"p": {
"abcd1": null,
"abcd2": null
}
}
}
unsubscribe package
{
"brokr": {
"v": "1.0",
"t": "unsub",
"p": {
"abcd3": {
"topic": "notifications"
},
"abcd4": {
"topic": "new-topic"
}
}
}
}
and the response
{
"brokr": {
"v": "1.0",
"t": "pserr",
"p": {
"abcd3": null,
"abcd4": null
}
}
}
publish package
Request that server publishes messages on topics
There is no response to this request
{
"brokr": {
"v": "1.0",
"t": "pub",
"p": {
"notifications": [{"hello": "world"}]
}
}
}