Documentation
¶
Index ¶
- func NewKcpServer(addr string, processor iduck.Processor) (s *kcpServer, err error)
- func NewQUICServer(addr string, processor iduck.Processor, config *tls.Config) (s *quicServer, err error)
- func NewTcpServer(addr string, processor iduck.Processor) (s *tcpServer, err error)
- func NewWsServer(addr string, processor iduck.Processor) (s *wsServer, err error)
- type BroadcastNode
- func (bNode *BroadcastNode) AddConn(conn iduck.IConnection) error
- func (bNode *BroadcastNode) Complete() error
- func (bNode *BroadcastNode) DelConn(key string) error
- func (bNode *BroadcastNode) Destroy() error
- func (bNode *BroadcastNode) GetAllMessage() chan []interface{}
- func (bNode *BroadcastNode) OnProtocolMessage(msg interface{}) error
- func (bNode *BroadcastNode) OnRawMessage([]byte) error
- func (bNode *BroadcastNode) Serve()
- type FrameNode
- func (gr *FrameNode) AddConn(conn iduck.IConnection) error
- func (gr *FrameNode) Complete() error
- func (gr *FrameNode) DelConn(key string) error
- func (gr *FrameNode) Destroy() error
- func (gr *FrameNode) GetAllMessage() chan []interface{}
- func (gr *FrameNode) OnProtocolMessage(interface{}) error
- func (gr *FrameNode) OnRawMessage(msg []byte) error
- func (gr *FrameNode) Serve()
- type KCPConn
- type QuicStream
- func (s *QuicStream) AfterClose(cb func())
- func (s *QuicStream) Close() error
- func (s *QuicStream) GetData() interface{}
- func (s *QuicStream) GetNode() iduck.INode
- func (s *QuicStream) GetUuid() string
- func (s *QuicStream) IsClosed() bool
- func (s *QuicStream) ReadMsg()
- func (s *QuicStream) SetData(data interface{})
- func (s *QuicStream) SetNode(node iduck.INode)
- func (s *QuicStream) WriteMsg(message interface{})
- type TCPConn
- func (tc *TCPConn) AfterClose(cb func())
- func (tc *TCPConn) Close() error
- func (tc *TCPConn) GetData() interface{}
- func (tc *TCPConn) GetNode() iduck.INode
- func (tc *TCPConn) GetUuid() string
- func (tc *TCPConn) IsClosed() bool
- func (tc *TCPConn) ReadMsg()
- func (tc *TCPConn) SetData(data interface{})
- func (tc *TCPConn) SetNode(node iduck.INode)
- func (tc *TCPConn) WriteMsg(message interface{})
- type WSConn
- func (wc *WSConn) AfterClose(cb func())
- func (wc *WSConn) Close() error
- func (wc *WSConn) GetData() interface{}
- func (wc *WSConn) GetNode() iduck.INode
- func (wc *WSConn) GetUuid() string
- func (wc *WSConn) IsClosed() bool
- func (wc *WSConn) ReadMsg()
- func (wc *WSConn) SetData(data interface{})
- func (wc *WSConn) SetNode(node iduck.INode)
- func (wc *WSConn) WriteMsg(message interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewKcpServer ¶
NewKcpServer return a *kcpServer
func NewQUICServer ¶
func NewQUICServer(addr string, processor iduck.Processor, config *tls.Config) (s *quicServer, err error)
NewQUICServer return new quicServer
func NewTcpServer ¶
NewTcpServer return new tcpServer
Types ¶
type BroadcastNode ¶
type BroadcastNode struct {
// 节点ID
NodeId string
// 网络连接
Connections map[interface{}]iduck.IConnection
// contains filtered or unexported fields
}
BroadcastNode 广播转发节点
func NewBroadcastNode ¶
func NewBroadcastNode() *BroadcastNode
NewBroadcastNode return a new BroadcastNode
func (*BroadcastNode) AddConn ¶
func (bNode *BroadcastNode) AddConn(conn iduck.IConnection) error
AddConn by conn
func (*BroadcastNode) DelConn ¶
func (bNode *BroadcastNode) DelConn(key string) error
DelConn by key
func (*BroadcastNode) GetAllMessage ¶
func (bNode *BroadcastNode) GetAllMessage() chan []interface{}
GetAllMessage return chan []interface{}
func (*BroadcastNode) OnProtocolMessage ¶
func (bNode *BroadcastNode) OnProtocolMessage(msg interface{}) error
OnProtocolMessage interface
func (*BroadcastNode) OnRawMessage ¶
func (bNode *BroadcastNode) OnRawMessage([]byte) error
OnRawMessage bytes
type FrameNode ¶
type FrameNode struct {
// 节点ID
NodeId string
// 网络连接
Connections map[interface{}]iduck.IConnection
// 同步周期
FrameTicker *time.Ticker
// rand seed
RandSeed int64
// contains filtered or unexported fields
}
FrameNode 帧同步节点
func (*FrameNode) GetAllMessage ¶
func (gr *FrameNode) GetAllMessage() chan []interface{}
GetAllMessage return chan []interface
func (*FrameNode) OnProtocolMessage ¶
OnProtocolMessage interface
func (*FrameNode) OnRawMessage ¶
OnRawMessage msg
type QuicStream ¶
QuicStream is warped udp conn for luck
func NewQuicStream ¶
func NewQuicStream(stream quic.Stream, processor iduck.Processor) *QuicStream
NewQuicStream return new udp conn
func (*QuicStream) AfterClose ¶
func (s *QuicStream) AfterClose(cb func())
AfterClose conn call back
func (*QuicStream) IsClosed ¶
func (s *QuicStream) IsClosed() bool
IsClosed return the status of conn
func (*QuicStream) ReadMsg ¶
func (s *QuicStream) ReadMsg()
ReadMsg read | write end -> write | read end -> conn end
func (*QuicStream) WriteMsg ¶
func (s *QuicStream) WriteMsg(message interface{})
WriteMsg warp msg base on conn's processor
type TCPConn ¶
TCPConn is warped tcp conn for luck
func NewTcpConn ¶
NewTcpConn return new tcp conn