2018-04-04 04:01:26 +00:00
|
|
|
package net
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"git.loafle.net/commons/server-go"
|
2018-04-05 15:15:29 +00:00
|
|
|
"git.loafle.net/commons/server-go/socket"
|
2018-04-04 04:01:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Servlet interface {
|
2018-04-05 15:15:29 +00:00
|
|
|
socket.Servlet
|
2018-04-04 04:01:26 +00:00
|
|
|
|
|
|
|
Handshake(servletCtx server.ServletCtx, conn net.Conn) 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
|
|
|
|
}
|
|
|
|
|
2018-04-09 12:48:14 +00:00
|
|
|
func (s *Servlets) OnStart(serverCtx server.ServerCtx) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) OnStop(serverCtx server.ServerCtx) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
2018-04-04 08:36:23 +00:00
|
|
|
func (s *Servlets) Destroy(serverCtx server.ServerCtx) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
2018-04-04 16:51:34 +00:00
|
|
|
func (s *Servlets) Handshake(servletCtx server.ServletCtx, conn net.Conn) error {
|
|
|
|
return nil
|
2018-04-04 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 15:15:29 +00:00
|
|
|
func (s *Servlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn) {
|
2018-04-04 08:36:23 +00:00
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Servlets) Handle(servletCtx server.ServletCtx, stopChan <-chan struct{}, doneChan chan<- struct{}, readChan <-chan []byte, writeChan chan<- []byte) {
|
|
|
|
|
|
|
|
}
|
2018-04-04 16:51:34 +00:00
|
|
|
|
|
|
|
func (s *Servlets) OnDisconnect(servletCtx server.ServletCtx) {
|
|
|
|
//
|
|
|
|
}
|