websocket

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: 5 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.

Documentation

Overview

Package websocket SDK 需要实现的 websocket 定义。

Index

Constants

This section is empty.

Variables

View Source
var PanicBufLen = 1024

PanicBufLen Panic 堆栈大小

Functions

func PanicHandler

func PanicHandler(e interface{}, session *dto.Session)

PanicHandler 处理websocket场景的 panic ,打印堆栈

func Register

func Register(ws WebSocket)

Register 注册 websocket 实现

func RegisterHandlers

func RegisterHandlers(handlers ...interface{}) dto.Intent

RegisterHandlers 兼容老版本的注册方式

func RegisterResumeSignal

func RegisterResumeSignal(signal syscall.Signal)

RegisterResumeSignal 注册用于通知 client 将连接进行 resume 的信号

Types

type WebSocket

type WebSocket interface {
	// New 创建一个新的ws实例,需要传递 session 对象
	New(session dto.Session) WebSocket
	// Connect 连接到 wss 地址
	Connect() error
	// Identify 鉴权连接
	Identify() error
	// Session 拉取 session 信息,包括 token,shard,seq 等
	Session() *dto.Session
	// Resume 重连
	Resume() error
	// Listening 监听websocket事件
	Listening() error
	// Write 发送数据
	Write(message *dto.WSPayload) error
	// Close 关闭连接
	Close()
}

WebSocket 需要实现的接口

var (
	// ClientImpl websocket 实现
	ClientImpl WebSocket
	// ResumeSignal 用于强制 resume 连接的信号量
	ResumeSignal syscall.Signal
)

Directories

Path Synopsis
Package client 默认的 websocket client 实现。
Package client 默认的 websocket client 实现。

Jump to

Keyboard shortcuts

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