client

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionClosedEventHandle

type ConnectionClosedEventHandle func(conn *Websocket, err any)

type ConnectionOpenedEventHandle

type ConnectionOpenedEventHandle func(conn *Websocket)

type ConnectionReceivePacketEventHandle

type ConnectionReceivePacketEventHandle func(conn *Websocket, packet server.Packet)

type Websocket

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

Websocket websocket 客户端

func NewWebsocket

func NewWebsocket(addr string) *Websocket

NewWebsocket 创建 websocket 客户端

func (*Websocket) Close

func (slf *Websocket) Close()

Close 关闭

func (*Websocket) GetData

func (slf *Websocket) GetData(key string) any

GetData 获取数据

func (*Websocket) IsConnected

func (slf *Websocket) IsConnected() bool

IsConnected 是否已连接

func (Websocket) OnConnectionClosedEvent

func (slf Websocket) OnConnectionClosedEvent(conn *Websocket, err any)

func (Websocket) OnConnectionOpenedEvent

func (slf Websocket) OnConnectionOpenedEvent(conn *Websocket)

func (Websocket) OnConnectionReceivePacketEvent

func (slf Websocket) OnConnectionReceivePacketEvent(conn *Websocket, packet server.Packet)

func (Websocket) RegConnectionClosedEvent

func (slf Websocket) RegConnectionClosedEvent(handle ConnectionClosedEventHandle)

RegConnectionClosedEvent 注册连接关闭事件

func (Websocket) RegConnectionOpenedEvent

func (slf Websocket) RegConnectionOpenedEvent(handle ConnectionOpenedEventHandle)

RegConnectionOpenedEvent 注册连接打开事件

func (Websocket) RegConnectionReceivePacketEvent

func (slf Websocket) RegConnectionReceivePacketEvent(handle ConnectionReceivePacketEventHandle)

RegConnectionReceivePacketEvent 注册连接接收数据包事件

func (*Websocket) Run

func (slf *Websocket) Run() error

Run 启动

func (*Websocket) SetData

func (slf *Websocket) SetData(key string, value any)

SetData 设置数据

func (*Websocket) Write

func (slf *Websocket) Write(packet server.Packet)

Write 向连接中写入数据

  • messageType: websocket模式中指定消息类型

Jump to

Keyboard shortcuts

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