mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-15 21:31:56 +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));
|
||||
}
|
||||
|
||||
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
|
||||
// that messages are queued and delivered when the WebSocket reconnects.
|
||||
// A regular Subject can be used to discard messages sent when the WebSocket
|
||||
// is disconnected.
|
||||
this.uplink.next({
|
||||
'key': key,
|
||||
'data': data
|
||||
});
|
||||
// TODO: do this nicer?
|
||||
const message = {'key': key};
|
||||
if (data) {
|
||||
message['data'] = data;
|
||||
}
|
||||
if (trigger) {
|
||||
message['trigger'] = trigger;
|
||||
}
|
||||
this.uplink.next(message);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user