From f205a2fcd824f0a19459f7ddbdbd32c1387cd76c Mon Sep 17 00:00:00 2001 From: crusader Date: Sun, 1 Jul 2018 02:32:51 +0900 Subject: [PATCH] ing --- Gopkg.lock | 7 ++++--- config.json | 9 +++++---- server/server.go | 5 ++--- servlet/webapp-servlet.go | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 15857d2..442625e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -17,10 +17,11 @@ branch = "master" name = "git.loafle.net/commons/rpc-go" packages = [ + "codec", "protocol", "protocol/json" ] - revision = "ded75d227c68b0d64ae4467613e5a3b790968328" + revision = "b834f36e2bdb7e5ff93e83ab165ee0310895f6e7" [[projects]] branch = "master" @@ -30,7 +31,7 @@ "socket", "socket/web" ] - revision = "1c6419e15b8c2c9ca609d205bf907948a19c6f1d" + revision = "20a63b3de6efdc0942bfb4be21ddc64e2b76f59d" [[projects]] branch = "master" @@ -83,7 +84,7 @@ "server", "servlet" ] - revision = "1db82cb967f26a4cb4031e9fd8efe13031d1793c" + revision = "b7d6a6fcb39be4e5a376c6db4fd8fe7d6a2fe6bc" [[projects]] name = "github.com/BurntSushi/toml" diff --git a/config.json b/config.json index 5beee93..67bc7dd 100644 --- a/config.json +++ b/config.json @@ -6,15 +6,16 @@ "concurrency": 262144, "keepAlive": 60, "handshakeTimeout": 60, - "maxMessageSize": 16384, - "readBufferSize": 16384, - "writeBufferSize": 16384, + "maxMessageSize": 8192, + "readBufferSize": 8192, + "writeBufferSize": 8192, "readTimeout": 0, "writeTimeout": 0, "pongTimeout": 60, "pingTimeout": 10, "pingPeriod": 10, - "enableCompression": true + "enableCompression": false, + "compressionThreshold": 8192 }, "external": { "grpc": { diff --git a/server/server.go b/server/server.go index e591f58..666a21d 100644 --- a/server/server.go +++ b/server/server.go @@ -1,6 +1,7 @@ package server import ( + crc "git.loafle.net/commons/rpc-go/codec" crpj "git.loafle.net/commons/rpc-go/protocol/json" csgw "git.loafle.net/commons/server-go/socket/web" "git.loafle.net/overflow/member_gateway_rpc/config" @@ -8,13 +9,11 @@ import ( ) func New(_config *config.Config) *csgw.Server { - rpcServerCodec := crpj.NewServerCodec() - ws := &servlet.WebappServlets{ VerifyKey: _config.VerifyKey, SignKey: _config.SignKey, } - ws.RPCServerCodec = rpcServerCodec + ws.RPCServerCodec = crpj.NewCustomServerCodec(crc.NewCompressionCodecSelector(_config.ServerHandler.GetCompressionThreshold())) ws.UseSession = true sh := &ServerHandlers{ diff --git a/servlet/webapp-servlet.go b/servlet/webapp-servlet.go index 04935e3..9dc3008 100644 --- a/servlet/webapp-servlet.go +++ b/servlet/webapp-servlet.go @@ -6,7 +6,7 @@ import ( "git.loafle.net/commons/logging-go" "git.loafle.net/commons/server-go" - "git.loafle.net/commons/server-go/socket" + css "git.loafle.net/commons/server-go/socket" oe "git.loafle.net/overflow/external-go" og "git.loafle.net/overflow/gateway" ogs "git.loafle.net/overflow/gateway/subscribe" @@ -96,7 +96,7 @@ func (s *WebappServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.R return nil, nil } -func (s *WebappServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn) { +func (s *WebappServlets) OnConnect(servletCtx server.ServletCtx, conn css.Conn) { s.RPCServlets.OnConnect(servletCtx, conn) } @@ -132,8 +132,8 @@ LOOP: for _, session := range sessions { _writeChan := session.ServletCtx.GetAttribute(og.SessionWriteChanKey) if nil != _writeChan { - writeChan := _writeChan.(chan<- []byte) - writeChan <- *msg.Message + writeChan := _writeChan.(chan<- css.SocketMessage) + writeChan <- css.MakeSocketMessage(css.TextMessage, *msg.Message) } } }