Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alber committed Sep 30, 2020
1 parent d18ec60 commit 1ab9040
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module gim
go 1.12

require (
github.com/alberliu/gn v1.1.0
github.com/alberliu/gn v1.2.0
github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec // indirect
github.com/go-redis/redis v6.14.2+incompatible
github.com/go-sql-driver/mysql v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/alberliu/gn v1.1.0 h1:rWmm7huvPP0NhuhaiMyK4YWmsoSDA5RcrA7jiAjFHns=
github.com/alberliu/gn v1.1.0/go.mod h1:EAZ/QNlcImJ4AkBwTgqUb73zW2ZuF7FxKIdEbjKLedE=
github.com/alberliu/gn v1.2.0 h1:hwwtVL6BNekdcxzr0EqJkrv38fXvO7rKugC9QpNUP/A=
github.com/alberliu/gn v1.2.0/go.mod h1:EAZ/QNlcImJ4AkBwTgqUb73zW2ZuF7FxKIdEbjKLedE=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down
4 changes: 2 additions & 2 deletions internal/tcp_conn/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type handler struct{}
var Handler = new(handler)

func (*handler) OnConnect(c *gn.Conn) {
logger.Logger.Debug("connect:", zap.Int("fd", c.GetFd()), zap.String("addr", c.GetAddr()))
logger.Logger.Debug("connect:", zap.Int32("fd", c.GetFd()), zap.String("addr", c.GetAddr()))
}
func (h *handler) OnMessage(c *gn.Conn, bytes []byte) {
var input pb.Input
Expand Down Expand Up @@ -91,7 +91,7 @@ func (h *handler) Send(c *gn.Conn, pt pb.PackageType, requestId int64, err error
return
}

err = gn.EncodeToFD(c.GetFd(), outputBytes)
err = encoder.EncodeToFD(c.GetFd(), outputBytes)
if err != nil {
logger.Sugar.Error(err)
return
Expand Down
4 changes: 3 additions & 1 deletion internal/tcp_conn/tcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"github.com/alberliu/gn"
)

var encoder = gn.NewHeaderLenEncoder(2, 1024)

var server *gn.Server

func StartTCPServer() {
var err error
server, err = gn.NewServer(config.TCPConn.TCPListenAddr, &handler{}, gn.WithReadMaxLen(254), gn.WithTimeout(5*time.Minute, 11*time.Minute))
server, err = gn.NewServer(config.TCPConn.TCPListenAddr, &handler{}, gn.NewHeaderLenDecoder(2, 254), gn.WithTimeout(5*time.Minute, 11*time.Minute))
if err != nil {
logger.Sugar.Error(err)
panic(err)
Expand Down

0 comments on commit 1ab9040

Please sign in to comment.