deprecated_overflow_gateway.../server_handlers.go
crusader 4146e11294 ing
2017-08-31 17:58:29 +09:00

57 lines
1.3 KiB
Go

package overflow_gateway_websocket
import (
"time"
uuid "github.com/satori/go.uuid"
"github.com/valyala/fasthttp"
)
// ServerHandlers is implementation of the Server handler interface
type ServerHandlers struct {
HandshakeTimeout time.Duration
ReadBufferSize int
WriteBufferSize int
EnableCompression bool
}
func (sh *ServerHandlers) GetHandshakeTimeout() time.Duration {
return sh.HandshakeTimeout
}
func (sh *ServerHandlers) GetReadBufferSize() int {
return sh.ReadBufferSize
}
func (sh *ServerHandlers) GetWriteBufferSize() int {
return sh.WriteBufferSize
}
func (sh *ServerHandlers) GetEnableCompression() bool {
return sh.EnableCompression
}
func (sh *ServerHandlers) OnConnection(soc Socket) {
}
func (sh *ServerHandlers) OnDisconnected(soc Socket) {
}
func (sh *ServerHandlers) OnCheckOrigin(ctx *fasthttp.RequestCtx) bool {
return true
}
func (sh *ServerHandlers) OnError(ctx *fasthttp.RequestCtx, status int, reason error) {
}
func (sh *ServerHandlers) OnIDGenerate(ctx *fasthttp.RequestCtx) string {
return uuid.NewV4().String()
}
// Validate validates the configuration
func (sh *ServerHandlers) Validate() {
if sh.ReadBufferSize <= 0 {
sh.ReadBufferSize = DefaultReadBufferSize
}
if sh.WriteBufferSize <= 0 {
sh.WriteBufferSize = DefaultWriteBufferSize
}
}