2018-04-04 04:01:26 +00:00
|
|
|
package websocket
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.loafle.net/commons/server-go"
|
|
|
|
"github.com/valyala/fasthttp"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Servlet interface {
|
|
|
|
server.Servlet
|
|
|
|
|
|
|
|
Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error)
|
|
|
|
}
|
2018-04-04 08:36:23 +00:00
|
|
|
|
|
|
|
type Servlets struct {
|
|
|
|
Servlet
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) ServletCtx(serverCtx server.ServerCtx) server.ServletCtx {
|
|
|
|
return server.NewServletContext(nil, serverCtx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) Init(serverCtx server.ServerCtx) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) Destroy(serverCtx server.ServerCtx) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) OnConnect(servletCtx server.ServletCtx, conn *server.Conn) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) OnDisconnect(servletCtx server.ServletCtx) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) Handle(servletCtx server.ServletCtx, stopChan <-chan struct{}, doneChan chan<- struct{}, readChan <-chan []byte, writeChan chan<- []byte) {
|
|
|
|
|
|
|
|
}
|