Documentation ¶
Index ¶
- Variables
- func NewMsgPack() *msgPack
- type Client
- func (c *Client) CallOnConnStart(conn gnet.IConnection)
- func (c *Client) CallOnConnStop(conn gnet.IConnection)
- func (c *Client) GetConn() gnet.IConnection
- func (c *Client) GetConnMgr() *gnet.ConnManager
- func (c *Client) GetHost() string
- func (c *Client) GetId() string
- func (c *Client) GetName() string
- func (c *Client) GetPort() int32
- func (c *Client) GetRouter() *gnet.Router
- func (c *Client) Run()
- func (c *Client) SetOnConnStart(connCallback gnet.ConnCallback)
- func (c *Client) SetOnConnStop(connCallback gnet.ConnCallback)
- func (c *Client) Start()
- func (c *Client) Stop()
- type Connection
- func (c *Connection) GetConnID() uint32
- func (c *Connection) GetProtocolType() gnet.ProtocolType
- func (c *Connection) GetSocket() gnet.ISocket
- func (c *Connection) GetTcpConnection() *net.TCPConn
- func (c *Connection) GetWsConnection() *websocket.Conn
- func (c *Connection) IsClosed() bool
- func (c *Connection) RemoteAddr() net.Addr
- func (c *Connection) SendMsg(msgId uint32, data []byte) error
- func (c *Connection) SetClosed() bool
- func (c *Connection) Start()
- func (c *Connection) StartReader()
- func (c *Connection) StartWriter()
- func (c *Connection) Stop()
- type Server
- func (s *Server) CallOnConnStart(conn gnet.IConnection)
- func (s *Server) CallOnConnStop(conn gnet.IConnection)
- func (s *Server) GetConnMgr() *gnet.ConnManager
- func (s *Server) GetHost() string
- func (s *Server) GetId() string
- func (s *Server) GetName() string
- func (s *Server) GetPort() int32
- func (s *Server) GetRouter() *gnet.Router
- func (s *Server) Run()
- func (s *Server) SetOnConnStart(connCallback gnet.ConnCallback)
- func (s *Server) SetOnConnStop(connCallback gnet.ConnCallback)
- func (s *Server) Start()
- func (s *Server) Stop()
Constants ¶
This section is empty.
Variables ¶
View Source
var MsgPack = NewMsgPack()
Functions ¶
func NewMsgPack ¶
func NewMsgPack() *msgPack
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 客户端暂时只支持TCP链接
func (*Client) CallOnConnStart ¶
func (c *Client) CallOnConnStart(conn gnet.IConnection)
func (*Client) CallOnConnStop ¶
func (c *Client) CallOnConnStop(conn gnet.IConnection)
func (*Client) GetConn ¶
func (c *Client) GetConn() gnet.IConnection
func (*Client) GetConnMgr ¶
func (c *Client) GetConnMgr() *gnet.ConnManager
func (*Client) SetOnConnStart ¶
func (c *Client) SetOnConnStart(connCallback gnet.ConnCallback)
func (*Client) SetOnConnStop ¶
func (c *Client) SetOnConnStop(connCallback gnet.ConnCallback)
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(socket gnet.ISocket, conn *net.TCPConn, connID uint32, msgHandler *gnet.MsgHandler, maxMsgChanLen uint32) *Connection
NewConnection 创建新的链接对象
func (*Connection) GetConnID ¶
func (c *Connection) GetConnID() uint32
func (*Connection) GetProtocolType ¶
func (c *Connection) GetProtocolType() gnet.ProtocolType
func (*Connection) GetSocket ¶
func (c *Connection) GetSocket() gnet.ISocket
func (*Connection) GetTcpConnection ¶
func (c *Connection) GetTcpConnection() *net.TCPConn
func (*Connection) GetWsConnection ¶
func (c *Connection) GetWsConnection() *websocket.Conn
func (*Connection) IsClosed ¶
func (c *Connection) IsClosed() bool
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
func (*Connection) SetClosed ¶
func (c *Connection) SetClosed() bool
func (*Connection) Start ¶
func (c *Connection) Start()
func (*Connection) StartReader ¶
func (c *Connection) StartReader()
StartReader 读消息Goroutine,用于从客户端中读取数据
func (*Connection) StartWriter ¶
func (c *Connection) StartWriter()
StartWriter 写消息Goroutine, 用户将数据发送给客户端
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server 定义一个Server服务类,实现interfaces.IServer接口
func (*Server) CallOnConnStart ¶
func (s *Server) CallOnConnStart(conn gnet.IConnection)
CallOnConnStart 调用连接OnConnStart Hook函数
func (*Server) CallOnConnStop ¶
func (s *Server) CallOnConnStop(conn gnet.IConnection)
CallOnConnStop 调用连接OnConnStop Hook函数
func (*Server) SetOnConnStart ¶
func (s *Server) SetOnConnStart(connCallback gnet.ConnCallback)
SetOnConnStart 设置服务器有新的链接Hook函数
func (*Server) SetOnConnStop ¶
func (s *Server) SetOnConnStop(connCallback gnet.ConnCallback)
SetOnConnStop 设置服务器有链接断开Hook函数
Click to show internal directories.
Click to hide internal directories.