gtcp

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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 NewClient

func NewClient(clientId string, clientName string, remoteIP string, remotePort int32) *Client

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) GetHost

func (c *Client) GetHost() string

func (*Client) GetId

func (c *Client) GetId() string

GetId 获取客户端ID

func (*Client) GetName

func (c *Client) GetName() string

GetName 获取客户端名称

func (*Client) GetPort

func (c *Client) GetPort() int32

func (*Client) GetRouter

func (c *Client) GetRouter() *gnet.Router

func (*Client) Run

func (c *Client) Run()

func (*Client) SetOnConnStart

func (c *Client) SetOnConnStart(connCallback gnet.ConnCallback)

func (*Client) SetOnConnStop

func (c *Client) SetOnConnStop(connCallback gnet.ConnCallback)

func (*Client) Start

func (c *Client) Start()

Start 开启

func (*Client) Stop

func (c *Client) Stop()

Stop 关闭

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) SendMsg

func (c *Connection) SendMsg(msgId uint32, data []byte) error

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, 用户将数据发送给客户端

func (*Connection) Stop

func (c *Connection) Stop()

Stop 停止连接,结束当前连接状态

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server 定义一个Server服务类,实现interfaces.IServer接口

func NewServer

func NewServer() *Server

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) GetConnMgr

func (s *Server) GetConnMgr() *gnet.ConnManager

GetConnMgr 获取链接管理器

func (*Server) GetHost

func (s *Server) GetHost() string

GetHost 获取服务器IP地址

func (*Server) GetId

func (s *Server) GetId() string

GetId 获取服务器ID

func (*Server) GetName

func (s *Server) GetName() string

GetName 获取服务器名称

func (*Server) GetPort

func (s *Server) GetPort() int32

GetPort 获取服务器端口

func (*Server) GetRouter

func (s *Server) GetRouter() *gnet.Router

func (*Server) Run

func (s *Server) Run()

Run 运行服务器

func (*Server) SetOnConnStart

func (s *Server) SetOnConnStart(connCallback gnet.ConnCallback)

SetOnConnStart 设置服务器有新的链接Hook函数

func (*Server) SetOnConnStop

func (s *Server) SetOnConnStop(connCallback gnet.ConnCallback)

SetOnConnStop 设置服务器有链接断开Hook函数

func (*Server) Start

func (s *Server) Start()

Start 启动服务器

func (*Server) Stop

func (s *Server) Stop()

Stop 停止服务器

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL