robot

package
v1.99.45 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(data interface{})

Callback 函数调用

type HandShakeResp

type HandShakeResp struct {
	Code int         `json:"code"`
	Sys  SysStruct   `json:"sys"`
	User interface{} `json:"user,omitempty"`
}

HandShakeResp 握手响应包

type HandleRobot

type HandleRobot interface {
	OnMessage(c *WsConnector, msg interface{})              // 收到消息
	OnConnected(c *WsConnector)                             // 首次连接成功后
	GetResponseInterfaceByRouter(router string) interface{} // 根据路由获取 response 类型
}

HandleRobot 处理机器人接口

type SysStruct

type SysStruct struct {
	// Type       string      `json:"type"`
	// Version    string      `json:"version"`
	Heartbeat  int         `json:"heartbeat,omitempty"`
	Servertime int64       `json:"servertime,omitempty"`
	Dict       interface{} `json:"dict"`
}

type WsConnector

type WsConnector struct {
	// contains filtered or unexported fields
}

ws连接

func NewConnector

func NewConnector(handler HandleRobot) *WsConnector

NewConnector 新建 robot connector

func (*WsConnector) Request

func (c *WsConnector) Request(route string, data interface{})

Request 使用 chanResp 传输

func (*WsConnector) RequestWithCallback

func (c *WsConnector) RequestWithCallback(route string, data interface{}, cb func(data interface{}))

func (*WsConnector) Start

func (c *WsConnector) Start(host string, port int, path string)

Start 握手,连接,

Jump to

Keyboard shortcuts

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