diff options
Diffstat (limited to 'api/websocket.go')
-rw-r--r-- | api/websocket.go | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/api/websocket.go b/api/websocket.go index 1c3277497..11ae09036 100644 --- a/api/websocket.go +++ b/api/websocket.go @@ -4,27 +4,25 @@ package api import ( + "net/http" + l4g "github.com/alecthomas/log4go" "github.com/gorilla/websocket" + "github.com/mattermost/platform/app" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" - "net/http" -) - -const ( - SOCKET_MAX_MESSAGE_SIZE_KB = 8 * 1024 // 8KB ) func InitWebSocket() { l4g.Debug(utils.T("api.web_socket.init.debug")) BaseRoutes.Users.Handle("/websocket", ApiAppHandlerTrustRequester(connect)).Methods("GET") - HubStart() + app.HubStart() } func connect(c *Context, w http.ResponseWriter, r *http.Request) { upgrader := websocket.Upgrader{ - ReadBufferSize: SOCKET_MAX_MESSAGE_SIZE_KB, - WriteBufferSize: SOCKET_MAX_MESSAGE_SIZE_KB, + ReadBufferSize: model.SOCKET_MAX_MESSAGE_SIZE_KB, + WriteBufferSize: model.SOCKET_MAX_MESSAGE_SIZE_KB, CheckOrigin: func(r *http.Request) bool { return true }, @@ -37,8 +35,8 @@ func connect(c *Context, w http.ResponseWriter, r *http.Request) { return } - wc := NewWebConn(c, ws) - HubRegister(wc) - go wc.writePump() - wc.readPump() + wc := app.NewWebConn(ws, c.Session, c.T, c.Locale) + app.HubRegister(wc) + go wc.WritePump() + wc.ReadPump() } |