diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-10-31 08:59:23 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-10-31 08:59:23 -0400 |
commit | 316b155a42a4d00fb835438ce7e0401a64e59add (patch) | |
tree | 6a64f05e948323ae7595971608d84a4420a08290 /webapp/client/websocket_client.jsx | |
parent | ef363fd88ebb731dbb0470ad7cb5f50de0f3845c (diff) | |
download | chat-316b155a42a4d00fb835438ce7e0401a64e59add.tar.gz chat-316b155a42a4d00fb835438ce7e0401a64e59add.tar.bz2 chat-316b155a42a4d00fb835438ce7e0401a64e59add.zip |
PLT-3562 Switch websocket over to post-connect authentication (#4327)
* Switch websocket over to post-connect authentication
* Add ability to specify token in websocket js driver, add unit tests
* Temporarily disable client websocket tests until issues are resolved
* Minor refactoring and fix status test
* Add isAuthenticated method to WebConn and minor status updates
Diffstat (limited to 'webapp/client/websocket_client.jsx')
-rw-r--r-- | webapp/client/websocket_client.jsx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/webapp/client/websocket_client.jsx b/webapp/client/websocket_client.jsx index 035e30be5..760c62b59 100644 --- a/webapp/client/websocket_client.jsx +++ b/webapp/client/websocket_client.jsx @@ -18,7 +18,7 @@ export default class WebSocketClient { this.closeCallback = null; } - initialize(connectionUrl) { + initialize(connectionUrl, token) { if (this.conn) { return; } @@ -30,6 +30,10 @@ export default class WebSocketClient { this.conn = new WebSocket(connectionUrl); this.conn.onopen = () => { + if (token) { + this.sendMessage('authentication_challenge', {token}); + } + if (this.connectFailCount > 0) { console.log('websocket re-established connection'); //eslint-disable-line no-console if (this.reconnectCallback) { @@ -68,7 +72,7 @@ export default class WebSocketClient { setTimeout( () => { - this.initialize(connectionUrl); + this.initialize(connectionUrl, token); }, retryTime ); @@ -152,12 +156,12 @@ export default class WebSocketClient { } } - userTyping(channelId, parentId) { + userTyping(channelId, parentId, callback) { const data = {}; data.channel_id = channelId; data.parent_id = parentId; - this.sendMessage('user_typing', data); + this.sendMessage('user_typing', data, callback); } getStatuses(callback) { |