ws

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EOF = []byte("EOF")

Functions

This section is empty.

Types

type Message

type Message []byte

type WsHub

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

WsHub todo 优化:使用占位符逻辑,当 key 生成就放入,只有放入了 key 才能写消息,优化任意 topic 的消息都能写入造成内存泄漏。

func NewHub

func NewHub() *WsHub

func (*WsHub) Add

func (h *WsHub) Add(key string, conn *websocket.Conn)

func (*WsHub) Close

func (h *WsHub) Close(key string)

func (*WsHub) GetKeyWrite

func (h *WsHub) GetKeyWrite(key string) interface {
	io.Writer
	io.Closer
}

func (*WsHub) Send

func (h *WsHub) Send(key string, body []byte) error

func (*WsHub) SendAll

func (h *WsHub) SendAll(body []byte) error

Jump to

Keyboard shortcuts

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