websocket_fasthttp/server_handler.go

60 lines
1.4 KiB
Go
Raw Normal View History

2017-11-07 10:03:40 +00:00
package websocket_fasthttp
import (
"net"
"time"
"github.com/valyala/fasthttp"
)
type ServerHandler interface {
2017-11-27 14:30:18 +00:00
ServerContext() ServerContext
2017-11-10 09:45:48 +00:00
// Init invoked before the server is started
// If you override ths method, must call
//
// func (sh *ServerHandler) Init() error {
// if err := sh.ServerHandler.Init(); nil != err {
// return err
// }
// ...
// return nil
// }
2017-11-27 11:19:19 +00:00
Init(serverCTX ServerContext) error
Listen(serverCTX ServerContext) (net.Listener, error)
2017-11-10 09:45:48 +00:00
// OnStart invoked when server is started
// If you override ths method, must call
//
// func (sh *ServerHandler) OnStart() error {
// sh.ServerHandler.OnStart()
// ...
// return nil
// }
2017-11-27 11:19:19 +00:00
OnStart(serverCTX ServerContext)
2017-11-10 09:45:48 +00:00
2017-11-07 10:03:40 +00:00
CheckOrigin(ctx *fasthttp.RequestCtx) bool
2017-11-27 11:19:19 +00:00
OnError(serverCTX ServerContext, ctx *fasthttp.RequestCtx, status int, reason error)
2017-11-10 09:45:48 +00:00
// OnStop invoked when server is stopped
// If you override ths method, must call
//
// func (sh *ServerHandler) OnStop() {
// ...
// sh.ServerHandler.OnStop()
// }
2017-11-27 11:19:19 +00:00
OnStop(serverCTX ServerContext)
2017-11-07 10:03:40 +00:00
RegisterSocketHandler(path string, handler SocketHandler)
GetSocketHandler(path string) (SocketHandler, error)
GetName() string
GetConcurrency() int
GetMaxStopWaitTime() time.Duration
GetHandshakeTimeout() time.Duration
GetReadBufferSize() int
GetWriteBufferSize() int
GetReadTimeout() time.Duration
GetWriteTimeout() time.Duration
IsEnableCompression() bool
Validate()
}