File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,23 @@ new Promise((resolve, reject) => {
34
34
process . exit ( - 1 )
35
35
} )
36
36
37
+ /**
38
+ * this resolves an issue with lost web messages and the client rebooting endlessly -
39
+ * we need to have a listener attached to the client from the start so that it does
40
+ * not reconnect infinitely, internally
41
+ */
42
+ function workaroundWebsocketPackageLostIssue ( webSocketClient : WebSocketClient ) {
43
+ // after a hundred messages it should be ok to unregister - the actual
44
+ // listener should have been added by now.
45
+ let messageCount = 100 ;
46
+ const firstMessagesListener = ( e : any ) => {
47
+ if ( messageCount -- < 1 ) {
48
+ webSocketClient . removeMessageListener ( firstMessagesListener )
49
+ }
50
+ } ;
51
+ webSocketClient . addMessageListener ( firstMessagesListener )
52
+ }
53
+
54
+ workaroundWebsocketPackageLostIssue ( wsClient ) ;
55
+
37
56
wsClient . initialize ( wsUrl . toString ( ) , mattermostToken )
You can’t perform that action at this time.
0 commit comments