mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 12:22:54 +00:00 
			
		
		
		
	Add optional trigger argument to WebSocketService
This commit is contained in:
		@@ -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);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user