Documentation
¶
Index ¶
- type BaseServerHandler
- func (b *BaseServerHandler) Boot(_ BootServer, traverse TraverseBy) error
- func (b *BaseServerHandler) Close(_ trp.Channel, traverse TraverseBy) error
- func (b *BaseServerHandler) Error(_ trp.Channel, _ error, traverse TraverseBy)
- func (b *BaseServerHandler) Open(_ trp.Channel, traverse TraverseBy) error
- func (b *BaseServerHandler) Reader(_ trp.Channel, traverse TraverseBy) error
- type BootServer
- type ConnContext
- type DupServer
- func (sever *DupServer) AddHandler(handler ...ServerHandler)
- func (sever *DupServer) OnClose(conn trp.Channel)
- func (sever *DupServer) OnError(conn trp.Channel, err error)
- func (sever *DupServer) OnOpen(conn trp.Channel) error
- func (sever *DupServer) OnRead(conn trp.Channel) error
- func (sever *DupServer) Shutdown(ctx context.Context)
- func (sever *DupServer) Start() error
- type GChannel
- func (c *GChannel) ActiveTime() time.Time
- func (c *GChannel) Close() error
- func (c *GChannel) Discard(pos int) (discarded int, err error)
- func (c *GChannel) Done() <-chan struct{}
- func (c *GChannel) GetAttr(key lang.KeyType) (interface{}, bool)
- func (c *GChannel) GetConn() net.Conn
- func (c *GChannel) GetContext() *ConnContext
- func (c *GChannel) GetId() string
- func (c *GChannel) GetNetConn() net.Conn
- func (c *GChannel) GetReader() io.Reader
- func (c *GChannel) GetServer() *Server
- func (c *GChannel) GetWriter() io.Writer
- func (c *GChannel) IsClose() bool
- func (c *GChannel) IsHealthy() bool
- func (c *GChannel) LastTime() time.Time
- func (c *GChannel) LocalAddr() net.Addr
- func (c *GChannel) Next(pos int) ([]byte, error)
- func (c *GChannel) OnClose(event transport.CloseEvent)
- func (c *GChannel) Peek(n int) (buf []byte, err error)
- func (c *GChannel) Read(out []byte) (int, error)
- func (c *GChannel) ReadFull(out []byte) (int, error)
- func (c *GChannel) RemoteAddr() net.Addr
- func (c *GChannel) SendTo(by []byte, addr net.Addr) (int, error)
- func (c *GChannel) SetDeadline(t time.Time) error
- func (c *GChannel) SetReadDeadline(t time.Time) error
- func (c *GChannel) SetWriteDeadline(t time.Time) error
- func (c *GChannel) Write(out []byte) (int, error)
- type GContext
- type InitConnHandler
- type NewChannelFunction
- type Server
- func (sever *Server) AddHandler(handler ...ServerHandler)
- func (sever *Server) AddInitConnHandler(init InitConnHandler)
- func (sever *Server) Connections() map[string]*GChannel
- func (sever *Server) GetConnection(id string) (*GChannel, bool)
- func (sever *Server) GetPort() int
- func (sever *Server) OnBoot(engine gnet.Engine) (action gnet.Action)
- func (sever *Server) OnClose(c gnet.Conn, _ error) gnet.Action
- func (sever *Server) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)
- func (sever *Server) OnTraffic(c gnet.Conn) gnet.Action
- func (sever *Server) Shutdown(ctx context.Context)
- func (sever *Server) Start(opt ...ServerOption) error
- type ServerHandler
- type ServerOption
- type SmuxServerOption
- type TraverseBy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseServerHandler ¶
type BaseServerHandler struct {
}
func (*BaseServerHandler) Boot ¶
func (b *BaseServerHandler) Boot(_ BootServer, traverse TraverseBy) error
func (*BaseServerHandler) Close ¶
func (b *BaseServerHandler) Close(_ trp.Channel, traverse TraverseBy) error
func (*BaseServerHandler) Error ¶
func (b *BaseServerHandler) Error(_ trp.Channel, _ error, traverse TraverseBy)
func (*BaseServerHandler) Open ¶
func (b *BaseServerHandler) Open(_ trp.Channel, traverse TraverseBy) error
func (*BaseServerHandler) Reader ¶
func (b *BaseServerHandler) Reader(_ trp.Channel, traverse TraverseBy) error
type BootServer ¶
type BootServer interface {
Start(opt ...ServerOption) error
}
type ConnContext ¶
func NewConnContext ¶
func NewConnContext(isUdp bool, addr string) *ConnContext
func (*ConnContext) AddAttr ¶
func (receiver *ConnContext) AddAttr(key lang.KeyType, value interface{})
func (*ConnContext) GetAttr ¶
func (receiver *ConnContext) GetAttr(key lang.KeyType) (interface{}, bool)
func (*ConnContext) GetLastActive ¶
func (receiver *ConnContext) GetLastActive() time.Time
func (*ConnContext) LastActive ¶
func (receiver *ConnContext) LastActive()
type DupServer ¶
type DupServer struct {
// contains filtered or unexported fields
}
func NewDupServer ¶
func NewDupServer(port int, opt ...ServerOption) *DupServer
func (*DupServer) AddHandler ¶
func (sever *DupServer) AddHandler(handler ...ServerHandler)
type GChannel ¶
type GChannel struct {
Context *ConnContext
Server *Server
// contains filtered or unexported fields
}
GChannel @Description:
func (*GChannel) ActiveTime ¶
func (*GChannel) GetContext ¶
func (c *GChannel) GetContext() *ConnContext
func (*GChannel) GetNetConn ¶
func (*GChannel) OnClose ¶
func (c *GChannel) OnClose(event transport.CloseEvent)
func (*GChannel) RemoteAddr ¶
func (*GChannel) SetDeadline ¶
SetDeadline is a wrapper for gnet.conn.SetDeadline.
type InitConnHandler ¶
type InitConnHandler func(conn *GChannel)
type Server ¶
type Server struct {
*gnet.BuiltinEventEngine
InitConnHandler InitConnHandler
// contains filtered or unexported fields
}
Server /*
func (*Server) AddHandler ¶
func (sever *Server) AddHandler(handler ...ServerHandler)
func (*Server) AddInitConnHandler ¶
func (sever *Server) AddInitConnHandler(init InitConnHandler)
func (*Server) Connections ¶
func (*Server) Start ¶
func (sever *Server) Start(opt ...ServerOption) error
Start is function start tcp server.
type ServerHandler ¶
type ServerHandler interface {
//
// Close
// @Description: Shutdown conn notify.
// @param conn
//
Close(ch trp.Channel, traverse TraverseBy) error
//
// Open
// @Description: Open conn notify.
// @param conn
//
Open(ch trp.Channel, traverse TraverseBy) error
//
// Reader
// @Description: Reader conn data notify.
// @param conn
//
Reader(ch trp.Channel, traverse TraverseBy) error
Error(ch trp.Channel, error error, traverse TraverseBy)
Boot(server BootServer, traverse TraverseBy) error
}
type ServerOption ¶
type ServerOption func(opts *sOptions)
func WithNetwork ¶
func WithNetwork(pt lang.Network) ServerOption
WithNetwork WithProtocol This function takes a string parameter and returns a ServerOption
func WithNewChannelFunc ¶
func WithNewChannelFunc(nfunc NewChannelFunction) ServerOption
func WithServerSmux ¶
func WithServerSmux(smux *SmuxServerOption) ServerOption
WithServerSmux
@Description: @param smux @return ServerOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ServerOption
WithTimeout
@Description: @param timeout @return ServerOption
type SmuxServerOption ¶
type SmuxServerOption struct {
// contains filtered or unexported fields
}
SmuxServerOption @Description:
func DefaultServerSmux ¶
func DefaultServerSmux() *SmuxServerOption
type TraverseBy ¶
type TraverseBy func()
Click to show internal directories.
Click to hide internal directories.