commands

package
v0.0.0-...-7fba91e Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package commands 提供客户端命令实现

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivateRequest

type ActivateRequest struct {
	Code      string `json:"code"`       // 邀请码
	Username  string `json:"username"`   // 用户名
	PublicKey string `json:"public_key"` // Base64 编码的公钥
}

ActivateRequest 激活请求

type ActivateResponse

type ActivateResponse struct {
	Code    int    `json:"code"`    // 响应码
	Message string `json:"message"` // 响应消息
	Data    struct {
		Token   string `json:"token"`   // JWT token
		Version int    `json:"version"` // 凭证版本
	} `json:"data"`
}

ActivateResponse 激活响应

type ChallengeResponse

type ChallengeResponse struct {
	Code    int    `json:"code"`    // 响应码
	Message string `json:"message"` // 响应消息
	Data    struct {
		Nonce     string `json:"nonce"`      // 随机挑战值
		ExpiresIn int    `json:"expires_in"` // 过期时间(秒)
	} `json:"data"`
}

ChallengeResponse Challenge 响应

type ConnectConfig

type ConnectConfig struct {
	ServerURL string // WebSocket 服务器 URL (ws://host:port/ws)
}

ConnectConfig Connect 命令配置

type ConnectResult

type ConnectResult struct {
	UserID int64 // 用户 ID
}

ConnectResult Connect 命令结果

func Connect

func Connect(cfg *ConnectConfig) (*ConnectResult, error)

Connect 连接到服务器并保持长连接

type JoinConfig

type JoinConfig struct {
	ServerURL string // 服务端 URL
	Code      string // 邀请码
	Username  string // 用户名
}

JoinConfig Join 命令配置

type JoinResult

type JoinResult struct {
	Token   string // JWT token
	Version int    // 凭证版本
}

JoinResult Join 结果

func Join

func Join(cfg *JoinConfig) (*JoinResult, error)

Join 执行 join 流程

type LoginConfig

type LoginConfig struct {
	ServerURL string // 服务端 URL
}

LoginConfig Login 命令配置

type LoginRequest

type LoginRequest struct {
	Nonce     string `json:"nonce"`     // 挑战值
	Signature string `json:"signature"` // 签名
}

LoginRequest 登录请求

type LoginResponse

type LoginResponse struct {
	Code    int    `json:"code"`    // 响应码
	Message string `json:"message"` // 响应消息
	Data    struct {
		Token   string `json:"token"`   // 新的 JWT token
		Version int    `json:"version"` // 新的凭证版本
	} `json:"data"`
}

LoginResponse 登录响应

type LoginResult

type LoginResult struct {
	Token   string // 新的 JWT token
	Version int    // 新的凭证版本
}

LoginResult Login 结果

func Login

func Login(cfg *LoginConfig) (*LoginResult, error)

Login 执行登录流程

Jump to

Keyboard shortcuts

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