Files
zogo/wsc/session_protocol.go

25 lines
719 B
Go

// session_protocol.go 定义会话层协议:会话级 action 常量与心跳/注册消息。
// 业务 action(业务消息)由各业务模块自行定义,不放在框架层。
package wsc
// 会话级 action 常量:心跳与注册(所有业务共用)。
const (
ActionPing = "ping"
ActionPong = "pong"
ActionRegister = "register"
)
// PingReq 心跳请求(无业务字段)。
type PingReq struct{}
// PingResp 心跳响应(action=pong)。
type PingResp struct {
Time int64 `json:"time"`
}
// RegisterResp 注册(上线)响应(action=register,与请求共用同一 action)。
type RegisterResp struct {
Success bool `json:"success"`
Message string `json:"message"`
}