mywebsocket

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientBody

type ClientBody struct {
	Code int         `json:"code,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

type HandlerReadFunc

type HandlerReadFunc func(messageType int, p []byte, err error) //ID , MESSAGEID,内容

type MyWebSocket

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

func NewWebSocket

func NewWebSocket(url string, handlerFunc HandlerReadFunc, requestHeader http.Header, timeOut time.Duration) (*MyWebSocket, error)

websocket 初始化接口

addr 地址, path 域 handlerFunc 读到的消息回调 stateFunc 连接消息回调 timeOut 读取超时回调(0则永不超时)

func (*MyWebSocket) Close

func (wss *MyWebSocket) Close()

func (*MyWebSocket) SendMessage

func (wss *MyWebSocket) SendMessage(messageType int, p []byte) error

type WSMessageType

type WSMessageType uint8
const (
	WS_Login WSMessageType = 1 // 链接
	WS_Close WSMessageType = 2 // 断线
)

Jump to

Keyboard shortcuts

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