Documentation
¶
Index ¶
- Variables
- func CreateContextWithMessage(ctx context.Context, message *msg.RelayMsgBuf) context.Context
- func CreateContextWithNetID(ctx context.Context, netID int64) context.Context
- func MessageFromContext(ctx context.Context) *msg.RelayMsgBuf
- func Mylog(b bool, v ...interface{})
- func NetIDFromContext(ctx context.Context) int64
- func Register(cmd string, handler func(context.Context, WriteCloser))
- type Handler
- type HandlerFunc
- type MsgHandler
- type Server
- func (s *Server) Broadcast(msg *msg.RelayMsgBuf)
- func (s *Server) ConnsSize() int
- func (s *Server) GetInboundAndReset() int64
- func (s *Server) GetOutboundAndReset() int64
- func (s *Server) GetReadFlow() int64
- func (s *Server) GetSecondReadFlow() int64
- func (s *Server) GetSecondWriteFlow() int64
- func (s *Server) GetWriteFlow() int64
- func (s *Server) Start(l net.Listener) error
- func (s *Server) Stop()
- func (s *Server) Unicast(netid int64, msg *msg.RelayMsgBuf) error
- type ServerConn
- func (sc *ServerConn) Close()
- func (sc *ServerConn) GetIP() string
- func (sc *ServerConn) GetLocalAddr() string
- func (sc *ServerConn) GetName() string
- func (sc *ServerConn) GetNetID() int64
- func (sc *ServerConn) GetPort() string
- func (sc *ServerConn) GetRemoteAddr() string
- func (sc *ServerConn) SetConnName(name string)
- func (sc *ServerConn) Start()
- func (sc *ServerConn) Write(message *message.RelayMsgBuf) error
- type ServerOption
- func BufferSizeOption(indicator int) ServerOption
- func LogOpenOption(b bool) ServerOption
- func MaxConnectionsOption(indicator int) ServerOption
- func MaxFlowOption(indicator int) ServerOption
- func OnCloseOption(cb func(WriteCloser)) ServerOption
- func OnConnectOption(cb func(WriteCloser) bool) ServerOption
- func OnErrorOption(cb func(WriteCloser)) ServerOption
- func OnMessageOption(cb func(msg.RelayMsgBuf, WriteCloser)) ServerOption
- type TaskPool
- type WriteCloser
Constants ¶
This section is empty.
Variables ¶
View Source
var (
GoroutineMap = &sync.Map{}
)
GoroutineMap
Functions ¶
func CreateContextWithMessage ¶
CreateContextWithMessage
func CreateContextWithNetID ¶
CreateContextWithNetID
func MessageFromContext ¶
func MessageFromContext(ctx context.Context) *msg.RelayMsgBuf
MessageFromContext get msg from context
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server
func (*Server) GetInboundAndReset ¶ added in v0.5.0
func (*Server) GetOutboundAndReset ¶ added in v0.5.0
type ServerConn ¶
type ServerConn struct {
// contains filtered or unexported fields
}
ServerConn
func CreateServerConn ¶
func CreateServerConn(id int64, s *Server, c net.Conn) *ServerConn
CreateServerConn
func (*ServerConn) GetLocalAddr ¶ added in v0.5.0
func (sc *ServerConn) GetLocalAddr() string
func (*ServerConn) GetRemoteAddr ¶ added in v0.5.0
func (sc *ServerConn) GetRemoteAddr() string
func (*ServerConn) Write ¶
func (sc *ServerConn) Write(message *message.RelayMsgBuf) error
Write * error is caught at application layer, if it's utils.ErrWouldBlock,sleep and then continue write
type ServerOption ¶
type ServerOption func(*options)
ServerOption
func MaxConnectionsOption ¶
func MaxConnectionsOption(indicator int) ServerOption
MaxConnectionsOption
func OnMessageOption ¶
func OnMessageOption(cb func(msg.RelayMsgBuf, WriteCloser)) ServerOption
OnMessageOption
type TaskPool ¶
type TaskPool struct {
// contains filtered or unexported fields
}
TaskPool
var GlobalTaskPool *TaskPool
GlobalTaskPool
type WriteCloser ¶
type WriteCloser interface { Write(*message.RelayMsgBuf) error Close() }
WriteCloser
Click to show internal directories.
Click to hide internal directories.