Jweb

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const WebsocketCloseByServer = 4000

Variables

This section is empty.

Functions

func BroadCastByte

func BroadCastByte(data *[]byte, connList []*WebsocketConn) error

广播Byte数据

func BroadCastString

func BroadCastString(data string, connList []*WebsocketConn) error

广播String数据

func WebInit

func WebInit(config WebConfig) *http.Server

Types

type WebConfig added in v0.1.7

type WebConfig struct {
	Debug          bool
	Origin         bool
	Addr           string
	PublicKeyPath  string
	PrivateKeyPath string
	AccessWrite    io.Writer
	ErrorWrite     io.Writer
	RouteCall      func(r *gin.Engine)
}

type WebsocketCall

type WebsocketCall struct {
	WebsocketConnect   func(conn *WebsocketConn) (interface{}, error)
	WebsocketConnected func(conn *WebsocketConn) error
	WebsocketClosed    func(conn *WebsocketConn, code int, text string) error
	WebsocketReceiver  func(conn *WebsocketConn, data *[]byte) error
	WebsocketPong      func(conn *WebsocketConn, pingData string) (string, error)
	WebsocketError     func(text string, err error)
}

Websocket接口配置

type WebsocketConfig

type WebsocketConfig struct {
	WriteWaitTime time.Duration
	ReadWaitTime  time.Duration
	PingWaitTime  time.Duration
	PongWaitTime  time.Duration
	Call          WebsocketCall
}

Websocket配置参数

func (*WebsocketConfig) WsHandle

func (config *WebsocketConfig) WsHandle(c *gin.Context)

type WebsocketConn

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

Websocket连接

func (*WebsocketConn) Close

func (ws *WebsocketConn) Close(msg string, immediately bool)

主动关闭连接

func (*WebsocketConn) GetBindVal

func (ws *WebsocketConn) GetBindVal() interface{}

获取绑定值

func (*WebsocketConn) GetDeadline

func (ws *WebsocketConn) GetDeadline(t time.Duration) time.Time

设置读超时时间

func (*WebsocketConn) GetParm

func (ws *WebsocketConn) GetParm() WebsocketParm

获取参数值

func (*WebsocketConn) SendByte

func (ws *WebsocketConn) SendByte(data *[]byte)

发送Byte数据

func (*WebsocketConn) SendString

func (ws *WebsocketConn) SendString(data string)

发送String数据

type WebsocketParm

type WebsocketParm struct {
	WsClientMsg  string
	WsClientAddr string
}

Jump to

Keyboard shortcuts

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