mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-15 23:41:55 +00:00
Add optional trigger argument to WebSocketService
This commit is contained in:
parent
3b7b597b3c
commit
3b7c8daafe
@ -43,14 +43,19 @@ export class WebSocketService {
|
|||||||
return this.downlink.pipe(filter(message => message.key === key));
|
return this.downlink.pipe(filter(message => message.key === key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public send(key: string, data: any): void {
|
public send(key: string, data?: any, trigger?: any): void {
|
||||||
// If the WebSocket is not connected then the QueueingSubject will ensure
|
// If the WebSocket is not connected then the QueueingSubject will ensure
|
||||||
// that messages are queued and delivered when the WebSocket reconnects.
|
// that messages are queued and delivered when the WebSocket reconnects.
|
||||||
// A regular Subject can be used to discard messages sent when the WebSocket
|
// A regular Subject can be used to discard messages sent when the WebSocket
|
||||||
// is disconnected.
|
// is disconnected.
|
||||||
this.uplink.next({
|
// TODO: do this nicer?
|
||||||
'key': key,
|
const message = {'key': key};
|
||||||
'data': data
|
if (data) {
|
||||||
});
|
message['data'] = data;
|
||||||
|
}
|
||||||
|
if (trigger) {
|
||||||
|
message['trigger'] = trigger;
|
||||||
|
}
|
||||||
|
this.uplink.next(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user