fib-push
fib-push
is one global service in a fibjs runtime, which provides duplex communication based on websocket-like connection, and manage end-2-end connection & message queue with Channel. One global service is enough in most cases, so we don't support multiple instances of fib-push
at now.
fib-push
has so less code that you could learn about its mechanism and usage just by reading source code :)
Core Concept
Channel
is the pivot structure infib-push
.- There is one global
idles
variable for recording idle channel, when new idle channel added as tail, the head one would be delete and removed. - All message transmission is on json-encoded-format.
Usage
const push = ; push;var r = ;var ws = r; { return datafoo === 'bar';}// mount one channel named of 'channel_name'push;pushconsole // 0pushconsole // 1 console // {"timestamp":"2018-05-11T09:18:05.134Z","ch":"channel_name","data":{"foo":"bar"}}console // {foo: 'bar'}
View more useages in this repo's test/*.js