overflow_gateway_websocket/server/server.go

35 lines
865 B
Go
Raw Normal View History

2017-11-10 13:24:10 +00:00
package server
import (
2017-11-14 03:03:16 +00:00
"fmt"
2017-11-10 13:24:10 +00:00
2017-11-14 03:03:16 +00:00
"git.loafle.net/commons_go/logging"
cwf "git.loafle.net/commons_go/websocket_fasthttp"
2017-11-10 13:24:10 +00:00
"git.loafle.net/overflow/overflow_gateway_websocket/config"
)
2017-11-14 06:02:42 +00:00
func New(sh ServerHandler) Server {
2017-11-14 03:03:16 +00:00
if nil == config.Config.Server {
logging.Logger().Panic(fmt.Sprintf("Gateway Websocket: Config of server is not initialized"))
}
2017-11-10 13:24:10 +00:00
2017-11-14 06:02:42 +00:00
shs := sh.(*ServerHandlers)
2017-11-10 13:24:10 +00:00
2017-11-14 06:02:42 +00:00
shs.Name = config.Config.Server.Name
shs.Concurrency = config.Config.Server.Concurrency
shs.MaxStopWaitTime = config.Config.Server.MaxStopWaitTime
2017-11-14 03:03:16 +00:00
2017-11-14 06:02:42 +00:00
shs.HandshakeTimeout = config.Config.Websocket.HandshakeTimeout
shs.ReadBufferSize = config.Config.Websocket.ReadBufferSize
shs.WriteBufferSize = config.Config.Websocket.WriteBufferSize
shs.EnableCompression = config.Config.Websocket.EnableCompression
s := cwf.New(shs)
2017-11-14 03:03:16 +00:00
return s
2017-11-10 13:24:10 +00:00
}
2017-11-14 06:02:42 +00:00
type Server interface {
cwf.Server
}