client

package
v0.0.0-...-0b63ca9 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

client

websocket 客户端实现

依赖:

  • github.com/gorilla/websocket
  • github.com/tidwall/gjson

Documentation

Overview

Package client 默认的 websocket client 实现。

Index

Constants

View Source
const DefaultQueueSize = 10000

DefaultQueueSize 监听队列的缓冲长度

Variables

This section is empty.

Functions

func Setup

func Setup()

Setup 依赖注册

Types

type Client

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

Client websocket 连接客户端

func (*Client) Close

func (c *Client) Close()

Close 关闭连接

func (*Client) Connect

func (c *Client) Connect() error

Connect 连接到 websocket

func (*Client) Identify

func (c *Client) Identify() error

Identify 对一个连接进行鉴权,并声明监听的 shard 信息

func (*Client) Listening

func (c *Client) Listening() error

Listening 开始监听,会阻塞进程,内部会从事件队列不断的读取事件,解析后投递到注册的 event handler,如果读取消息过程中发生错误,会循环 定时心跳也在这里维护

func (*Client) New

func (c *Client) New(session dto.Session) websocket.WebSocket

New 新建一个连接对象

func (*Client) Resume

func (c *Client) Resume() error

Resume 重连

func (*Client) Session

func (c *Client) Session() *dto.Session

Session 获取client的session信息

func (*Client) Write

func (c *Client) Write(message *dto.WSPayload) error

Write 往 ws 写入数据

Jump to

Keyboard shortcuts

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