websocket

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WsDebug *bool

Functions

func WsHandler

func WsHandler(c *gin.Context)

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
	UserID     string `json:"user_id"`
	Token      string `json:"Token"` //认证用
	Detail     string `json:"detail"`
	DataString string `json:"data_string"` //附加的json字符串数据,服务器根据情况解析
}

Message 定义一个对象来管理消息,反引号包含的文本是 Go 在对象和 JSON 之间进行序列化和反序列化时需要的元数据。

type MessageWithClientID

type MessageWithClientID struct {
	Msg      Message
	ClientID string
}

Jump to

Keyboard shortcuts

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