websocket

package
v1.2.34 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WsDebug *bool

Functions

func WsHandler

func WsHandler(c echo.Context) error

WsHandler 路由是 "/ws",即 ws://127.0.0.1:1234/api/ws

Types

type Message

type Message struct {
	Type       string `json:"type"`
	StatusCode int    `json:"status_code"` // 参考http状态码: https://zh.wikipedia.org/zh-hans/HTTP%E7%8A%B6%E6%80%81%E7%A0%81
	TabID      string `json:"tab_id"`      // 前端页面的 Tab ID
	Detail     string `json:"detail"`
	DataString string `json:"data_string"`         // 附加的json字符串数据,服务器根据情况解析
	PageType   string `json:"page_type,omitempty"` // 当前页面类型:flip / scroll / shelf
	BookID     string `json:"book_id,omitempty"`   // 当前书籍 ID(可选)
}

Message 定义 WebSocket 同步消息结构。 认证边界在 /api/ws 路由连接层处理,单条消息不携带占位 token 字段。

type MessageWithClientID

type MessageWithClientID struct {
	Msg      Message
	ClientID string
	Client   *websocket.Conn
}

Jump to

Keyboard shortcuts

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