summaryrefslogtreecommitdiffstats
path: root/model/websocket_client.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-05-16 13:43:22 -0400
committerGitHub <noreply@github.com>2018-05-16 13:43:22 -0400
commit1f6c271b3bedd6656ae7155714423b1b39a669c1 (patch)
tree9ce6390c237cc5f7c16d63addb4372033807cff8 /model/websocket_client.go
parent02f8c18f40cd0e973e4c75b751e8fcbbbd019728 (diff)
downloadchat-1f6c271b3bedd6656ae7155714423b1b39a669c1.tar.gz
chat-1f6c271b3bedd6656ae7155714423b1b39a669c1.tar.bz2
chat-1f6c271b3bedd6656ae7155714423b1b39a669c1.zip
MM-8708 Remove api package (#8784)
* Remove api package * Remove api dependency from cmd package * Remove EnableAPIv3 setting * Update web tests * Add more websocket tests * Move some ws and oauth tests to api4 package * Move command tests into api4 package * Test fixes * Fix msg command test * Add some app file tests
Diffstat (limited to 'model/websocket_client.go')
-rw-r--r--model/websocket_client.go31
1 files changed, 4 insertions, 27 deletions
diff --git a/model/websocket_client.go b/model/websocket_client.go
index 788dbee20..4e6c1d8cc 100644
--- a/model/websocket_client.go
+++ b/model/websocket_client.go
@@ -39,15 +39,15 @@ func NewWebSocketClient(url, authToken string) (*WebSocketClient, *AppError) {
// NewWebSocketClientWithDialer constructs a new WebSocket client with convenience
// methods for talking to the server using a custom dialer.
func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, *AppError) {
- conn, _, err := dialer.Dial(url+API_URL_SUFFIX_V3+"/users/websocket", nil)
+ conn, _, err := dialer.Dial(url+API_URL_SUFFIX+"/websocket", nil)
if err != nil {
return nil, NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}
client := &WebSocketClient{
url,
- url + API_URL_SUFFIX_V3,
- url + API_URL_SUFFIX_V3 + "/users/websocket",
+ url + API_URL_SUFFIX,
+ url + API_URL_SUFFIX + "/websocket",
conn,
authToken,
1,
@@ -74,30 +74,7 @@ func NewWebSocketClient4(url, authToken string) (*WebSocketClient, *AppError) {
// NewWebSocketClient4WithDialer constructs a new WebSocket client with convenience
// methods for talking to the server using a custom dialer. Uses the v4 endpoint.
func NewWebSocketClient4WithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, *AppError) {
- conn, _, err := dialer.Dial(url+API_URL_SUFFIX+"/websocket", nil)
- if err != nil {
- return nil, NewAppError("NewWebSocketClient4", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
- }
-
- client := &WebSocketClient{
- url,
- url + API_URL_SUFFIX,
- url + API_URL_SUFFIX + "/websocket",
- conn,
- authToken,
- 1,
- make(chan bool, 1),
- make(chan *WebSocketEvent, 100),
- make(chan *WebSocketResponse, 100),
- nil,
- nil,
- }
-
- client.configurePingHandling()
-
- client.SendMessage(WEBSOCKET_AUTHENTICATION_CHALLENGE, map[string]interface{}{"token": authToken})
-
- return client, nil
+ return NewWebSocketClientWithDialer(dialer, url, authToken)
}
func (wsc *WebSocketClient) Connect() *AppError {