Make client support ping

This commit is contained in:
Tony Garnock-Jones 2019-03-18 23:29:43 +00:00
parent d46eec2e6d
commit 50ee261c0f
2 changed files with 8 additions and 0 deletions

View File

@ -11,6 +11,7 @@ const WS = activate require("@syndicate-lang/driver-websocket");
const {
Assert, Clear, Message,
Add, Del, Msg,
Ping, Pong,
makeDecoder,
} = activate require("./protocol");
@ -56,6 +57,8 @@ spawn named "BrokerClientFactory" {
on message ToBroker(url, $a) w(Message(a));
on message _BrokerPacket(url, Ping()) w(Pong());
during Observe(FromBroker(url, $spec)) {
const ep = genUuid('sub');
on start w(Assert(ep, Observe(spec)));

View File

@ -12,6 +12,10 @@ message type Add(endpointName, captures);
message type Del(endpointName, captures);
message type Msg(endpointName, captures);
// Bidirectional
message type Ping();
message type Pong();
function makeDecoder(initialBuffer) {
return new Decoder(initialBuffer, {
shortForms: {
@ -25,5 +29,6 @@ function makeDecoder(initialBuffer) {
Object.assign(module.exports, {
Assert, Clear, Message,
Add, Del, Msg,
Ping, Pong,
makeDecoder,
});