Documentation
¶
Index ¶
- type Client
- func (c *Client) ConnectWebSocket() (*WSClient, error)
- func (c *Client) GetMessageHistory(params MessageQueryParams) (*MessageQueryResult, error)
- func (c *Client) Login(email, password string) error
- func (c *Client) RefreshToken() error
- func (c *Client) Register(email, password, name string) error
- func (c *Client) SendMessage(msgType string, content interface{}) error
- func (c *Client) SendText(text string) error
- func (c *Client) UpdatePassword(oldPassword, newPassword string) error
- func (c *Client) UpdateProfile(name string) error
- type Config
- type ErrorResponse
- type HeartbeatConfig
- type LoginRequest
- type Message
- type MessageHandler
- type MessageQueryParams
- type MessageQueryResult
- type RegisterRequest
- type TextMessage
- type Time
- type TokenResponse
- type UpdatePasswordRequest
- type UpdateProfileRequest
- type WSClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 聊天机器人客户端
func (*Client) ConnectWebSocket ¶
ConnectWebSocket 连接WebSocket服务器
func (*Client) GetMessageHistory ¶
func (c *Client) GetMessageHistory(params MessageQueryParams) (*MessageQueryResult, error)
GetMessageHistory 获取消息历史
func (*Client) SendMessage ¶
SendMessage 发送消息
func (*Client) UpdatePassword ¶
UpdatePassword 更新密码
func (*Client) UpdateProfile ¶
UpdateProfile 更新用户资料
type Config ¶
type Config struct { BaseURL string // API基础URL Timeout time.Duration // HTTP请求超时时间 AuthToken string // JWT认证token UserAgent string // User-Agent Debug bool // 是否开启调试模式 }
Config 客户端配置
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code"` Message string `json:"message"` ErrorMsg string `json:"error,omitempty"` }
ErrorResponse API错误响应
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type HeartbeatConfig ¶
type HeartbeatConfig struct { MinInterval time.Duration MaxInterval time.Duration InitialInterval time.Duration AdjustFactor float64 RTTThreshold time.Duration }
HeartbeatConfig 心跳配置
type LoginRequest ¶
LoginRequest 登录请求参数
type Message ¶
type Message struct { ID uint `json:"id"` Content string `json:"content"` Type string `json:"type"` Sender string `json:"sender"` Seq uint `json:"seq"` SessionID uint `json:"session_id"` Extra json.RawMessage `json:"extra,omitempty"` CreatedAt Time `json:"created_at"` }
Message 消息结构
type MessageQueryParams ¶
type MessageQueryParams struct { SessionID *uint `json:"session_id,omitempty"` StartTime time.Time `json:"start_time,omitempty"` EndTime time.Time `json:"end_time,omitempty"` Page int `json:"page,omitempty"` PageSize int `json:"page_size,omitempty"` }
MessageQueryParams 消息查询参数
type MessageQueryResult ¶
MessageQueryResult 消息查询结果
type RegisterRequest ¶
type RegisterRequest struct { Email string `json:"email"` Password string `json:"password"` Name string `json:"name"` }
RegisterRequest 注册请求参数
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
}
TokenResponse token响应
type UpdatePasswordRequest ¶
type UpdatePasswordRequest struct { OldPassword string `json:"old_password"` NewPassword string `json:"new_password"` }
UpdatePasswordRequest 更新密码请求参数
type UpdateProfileRequest ¶
type UpdateProfileRequest struct {
Name string `json:"name"`
}
UpdateProfileRequest 更新资料请求参数
Click to show internal directories.
Click to hide internal directories.