package websocket_fasthttp import ( "time" "github.com/valyala/fasthttp" ) type SocketHandler interface { // Init invoked when server is stated // If you override ths method, must call // // func (sh *SocketHandler) Init() error { // if err := sh.SocketHandlers.Init(); nil != err { // return err // } // ... // ... // return nil // } Init() error // Handshake do handshake client and server // id is identity of client socket. if id is "", disallow connection Handshake(ctx *fasthttp.RequestCtx) (id string, extensionsHeader *fasthttp.ResponseHeader) // OnConnect invoked when client is connected // If you override ths method, must call // // func (sh *SocketHandler) OnConnect(soc cwf.Socket) cwf.Socket { // ... // newSoc := ... // return sh.SocketHandlers.OnConnect(newSoc) // } OnConnect(soc Socket) Socket Handle(soc Socket, stopChan <-chan struct{}, doneChan chan<- struct{}) // OnDisconnect invoked when client is disconnected // If you override ths method, must call // // func (sh *SocketHandler) OnDisconnect(soc cwf.Socket) { // ... // sh.SocketHandlers.OnDisconnect(soc) // } OnDisconnect(soc Socket) // Destroy invoked when server is stopped // If you override ths method, must call // // func (sh *SocketHandler) Destroy() { // ... // sh.SocketHandlers.Destroy() // } Destroy() GetSocket(id string) Socket GetSockets() map[string]Socket GetMaxMessageSize() int64 GetWriteTimeout() time.Duration GetReadTimeout() time.Duration GetPongTimeout() time.Duration GetPingTimeout() time.Duration GetPingPeriod() time.Duration // Validate is check handler value // If you override ths method, must call // // func (sh *SocketHandlers) Validate() { // sh.SocketHandlers.Validate() // ... // } Validate() }