xC/xP: finalize and implement Event.PING
This commit is contained in:
parent
3a165a595b
commit
8c3ee80b21
22
xC-proto
22
xC-proto
@ -8,11 +8,12 @@ struct CommandMessage {
|
|||||||
u32 command_seq;
|
u32 command_seq;
|
||||||
union CommandData switch (enum Command {
|
union CommandData switch (enum Command {
|
||||||
HELLO,
|
HELLO,
|
||||||
PING,
|
|
||||||
ACTIVE,
|
ACTIVE,
|
||||||
BUFFER_COMPLETE,
|
|
||||||
BUFFER_INPUT,
|
BUFFER_INPUT,
|
||||||
BUFFER_ACTIVATE,
|
BUFFER_ACTIVATE,
|
||||||
|
PING_RESPONSE,
|
||||||
|
PING,
|
||||||
|
BUFFER_COMPLETE,
|
||||||
BUFFER_LOG,
|
BUFFER_LOG,
|
||||||
} command) {
|
} command) {
|
||||||
case HELLO:
|
case HELLO:
|
||||||
@ -20,19 +21,24 @@ struct CommandMessage {
|
|||||||
// If the version check succeeds, the client will receive
|
// If the version check succeeds, the client will receive
|
||||||
// an initial stream of BUFFER_UPDATE, BUFFER_LINE,
|
// an initial stream of BUFFER_UPDATE, BUFFER_LINE,
|
||||||
// and finally a BUFFER_ACTIVATE message.
|
// and finally a BUFFER_ACTIVATE message.
|
||||||
case PING:
|
|
||||||
void;
|
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
void;
|
void;
|
||||||
case BUFFER_COMPLETE:
|
|
||||||
string buffer_name;
|
|
||||||
string text;
|
|
||||||
u32 position;
|
|
||||||
case BUFFER_INPUT:
|
case BUFFER_INPUT:
|
||||||
string buffer_name;
|
string buffer_name;
|
||||||
string text;
|
string text;
|
||||||
case BUFFER_ACTIVATE:
|
case BUFFER_ACTIVATE:
|
||||||
string buffer_name;
|
string buffer_name;
|
||||||
|
case PING_RESPONSE:
|
||||||
|
u32 event_seq;
|
||||||
|
|
||||||
|
// Only these commands may produce Event.RESPONSE, as below,
|
||||||
|
// but any command may produce an error.
|
||||||
|
case PING:
|
||||||
|
void;
|
||||||
|
case BUFFER_COMPLETE:
|
||||||
|
string buffer_name;
|
||||||
|
string text;
|
||||||
|
u32 position;
|
||||||
case BUFFER_LOG:
|
case BUFFER_LOG:
|
||||||
string buffer_name;
|
string buffer_name;
|
||||||
} data;
|
} data;
|
||||||
|
@ -85,7 +85,8 @@ class RelayRpc extends EventTarget {
|
|||||||
if (typeof e.event !== 'string')
|
if (typeof e.event !== 'string')
|
||||||
throw "Invalid event tag"
|
throw "Invalid event tag"
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent(e.event, {detail: e}))
|
this.dispatchEvent(new CustomEvent(
|
||||||
|
e.event, {detail: {eventSeq: message.eventSeq, ...e}}))
|
||||||
|
|
||||||
// Minor abstraction layering violation.
|
// Minor abstraction layering violation.
|
||||||
m.redraw()
|
m.redraw()
|
||||||
@ -153,6 +154,10 @@ rpc.addEventListener('close', event => {
|
|||||||
m.redraw()
|
m.redraw()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
rpc.addEventListener('Ping', event => {
|
||||||
|
rpc.send({command: 'PingResponse', eventSeq: event.detail.eventSeq})
|
||||||
|
})
|
||||||
|
|
||||||
rpc.addEventListener('BufferUpdate', event => {
|
rpc.addEventListener('BufferUpdate', event => {
|
||||||
let e = event.detail, b = buffers.get(e.bufferName)
|
let e = event.detail, b = buffers.get(e.bufferName)
|
||||||
if (b === undefined) {
|
if (b === undefined) {
|
||||||
|
Loading…
Reference in New Issue
Block a user