client

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

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

Jump to

Keyboard shortcuts

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