mywebsocket

package
v0.0.0-...-4215923 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitWebSocket

func InitWebSocket(pathExp string, handlerFunc HandlerReadFunc, stateFunc HandlerStateFunc, timeOut time.Duration, isMult bool) *rest.Route

websocket 初始化接口

pathExp 域, handlerFunc 读到的消息回调 stateFunc 连接消息回调 timeOut 读取超时回调(0则永不超时) isMult 是否多用户登录

func WriteData

func WriteData(pathExp string, clientid string, body ClientBody) bool

写数据 pathExp:请求的根路径 clientid:发送人id body:发送内容

Types

type ClientBody

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

type HandlerReadFunc

type HandlerReadFunc func(string, string, ClientBody, *websocket.Conn) //ID , MESSAGEID,内容

type HandlerStateFunc

type HandlerStateFunc func(string, string, WSMessageType) //状态发声改变回调

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