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