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
Этот коммит содержится в:
Joram Wilander
2016-10-31 08:59:23 -04:00
коммит произвёл Christopher Speller
родитель ef363fd88e
Коммит 316b155a42
12 изменённых файлов: 279 добавлений и 26 удалений

Просмотреть файл

@@ -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) {