Documentation ¶
Index ¶
- type Client
- func (slf *Client) Close(err ...error)
- func (slf *Client) GetServerAddr() string
- func (slf *Client) IsConnected() bool
- func (slf Client) OnConnectionClosedEvent(conn *Client, err any)
- func (slf Client) OnConnectionOpenedEvent(conn *Client)
- func (slf Client) OnConnectionReceivePacketEvent(conn *Client, wst int, packet []byte)
- func (slf Client) RegConnectionClosedEvent(handle ConnectionClosedEventHandle)
- func (slf Client) RegConnectionOpenedEvent(handle ConnectionOpenedEventHandle)
- func (slf Client) RegConnectionReceivePacketEvent(handle ConnectionReceivePacketEventHandle)
- func (slf *Client) Run(block ...bool) error
- func (slf *Client) Write(packet []byte, callback ...func(err error))
- func (slf *Client) WriteWS(wst int, packet []byte, callback ...func(err error))
- type ConnectionClosedEventHandle
- type ConnectionOpenedEventHandle
- type ConnectionReceivePacketEventHandle
- type Core
- type Packet
- type TCP
- type UnixDomainSocket
- type Websocket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.1.0
type Client struct {
// contains filtered or unexported fields
}
Client 客户端
func NewUnixDomainSocket ¶ added in v0.0.31
func (*Client) GetServerAddr ¶ added in v0.1.0
GetServerAddr 获取服务器地址
func (*Client) IsConnected ¶ added in v0.1.0
IsConnected 是否已连接
func (Client) OnConnectionClosedEvent ¶ added in v0.1.0
func (Client) OnConnectionOpenedEvent ¶ added in v0.1.0
func (slf Client) OnConnectionOpenedEvent(conn *Client)
func (Client) OnConnectionReceivePacketEvent ¶ added in v0.1.0
func (Client) RegConnectionClosedEvent ¶ added in v0.1.0
func (slf Client) RegConnectionClosedEvent(handle ConnectionClosedEventHandle)
RegConnectionClosedEvent 注册连接关闭事件
func (Client) RegConnectionOpenedEvent ¶ added in v0.1.0
func (slf Client) RegConnectionOpenedEvent(handle ConnectionOpenedEventHandle)
RegConnectionOpenedEvent 注册连接打开事件
func (Client) RegConnectionReceivePacketEvent ¶ added in v0.1.0
func (slf Client) RegConnectionReceivePacketEvent(handle ConnectionReceivePacketEventHandle)
RegConnectionReceivePacketEvent 注册连接接收数据包事件
type ConnectionOpenedEventHandle ¶
type ConnectionOpenedEventHandle func(conn *Client)
type Core ¶ added in v0.1.0
type Core interface { // Run 启动客户端 // - runState: 运行状态,当客户端启动完成时,应该向该通道发送 error 或 nil // - receive: 接收到数据包时应该将数据包发送到该函数,wst 表示 websocket 的数据类型,data 表示数据包 Run(runState chan<- error, receive func(wst int, packet []byte)) // Write 向客户端写入数据包 Write(packet *Packet) error // Close 关闭客户端 Close() // GetServerAddr 获取服务器地址 GetServerAddr() string // Clone 克隆客户端 Clone() Core }
type TCP ¶ added in v0.1.1
type TCP struct {
// contains filtered or unexported fields
}
func (*TCP) GetServerAddr ¶ added in v0.1.1
type UnixDomainSocket ¶ added in v0.0.31
type UnixDomainSocket struct {
// contains filtered or unexported fields
}
func (*UnixDomainSocket) Clone ¶ added in v0.1.2
func (slf *UnixDomainSocket) Clone() Core
func (*UnixDomainSocket) Close ¶ added in v0.0.31
func (slf *UnixDomainSocket) Close()
func (*UnixDomainSocket) GetServerAddr ¶ added in v0.1.0
func (slf *UnixDomainSocket) GetServerAddr() string
func (*UnixDomainSocket) Run ¶ added in v0.0.31
func (slf *UnixDomainSocket) Run(runState chan<- error, receive func(wst int, packet []byte))
func (*UnixDomainSocket) Write ¶ added in v0.0.31
func (slf *UnixDomainSocket) Write(packet *Packet) error
Click to show internal directories.
Click to hide internal directories.