websocket

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bots = make(map[string]map[string]*Bot)

Functions

func NewPush

func NewPush(appid string, frame *onebot.Frame) error

func NewSecretPush added in v0.0.5

func NewSecretPush(appid, secret string, frame *onebot.Frame) error

func UpgradeWebsocket

func UpgradeWebsocket(w http.ResponseWriter, r *http.Request) error

func UpgradeWebsocketWithSecret added in v0.0.5

func UpgradeWebsocketWithSecret(w http.ResponseWriter, r *http.Request) error

Types

type Bot

type Bot struct {
	BotId     string
	BotSecret string
	Session   *SafeWebSocket

	WaitingFrames map[string]*promise.Promise
	// contains filtered or unexported fields
}

func NewBot

func NewBot(xSelfId string, addr string, conn *websocket.Conn) *Bot

func NewSecretBot added in v0.0.5

func NewSecretBot(xSelfId, xBotSecret string, addr string, conn *websocket.Conn) *Bot

type SafeWebSocket

type SafeWebSocket struct {
	Conn          *websocket.Conn
	SendChannel   chan *WebSocketSendingMessage
	OnRecvMessage func(messageType int, data []byte)
	OnClose       func(int, string)
}

safe websocket

func NewSafeWebSocket

func NewSafeWebSocket(appid string, conn *websocket.Conn, OnRecvMessage func(messageType int, data []byte), onClose func(int, string)) *SafeWebSocket

func (*SafeWebSocket) Send

func (ws *SafeWebSocket) Send(messageType int, data []byte)

type WebSocketSendingMessage

type WebSocketSendingMessage struct {
	MessageType int
	Data        []byte
}

Jump to

Keyboard shortcuts

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