From 97558f6a6ec4c53fa69035fb430ead209d9c222d Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 13 Jan 2017 13:53:37 -0500 Subject: PLT-4938 Add app package and move logic over from api package (#4931) * Add app package and move logic over from api package * Change app package functions to return errors * Move non-api tests into app package * Fix merge --- api/websocket.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'api/websocket.go') 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() } -- cgit v1.2.3-1-g7c22