ws

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

type Hub

type Hub struct {
	Broadcast chan MsgBody

	sync.Mutex
	// contains filtered or unexported fields
}

Hub maintains the set of active clients and broadcasts messages to the clients.

var (
	M *Hub
)

func NewHub

func NewHub() *Hub

func (*Hub) ServeWs

func (h *Hub) ServeWs(ctx *gin.Context)

serveWs handles websocket requests from the peer.

type MsgBody

type MsgBody struct {
	To       string
	Response Response
}

func (*MsgBody) BodyHash

func (m *MsgBody) BodyHash() string

func (*MsgBody) GetBody

func (m *MsgBody) GetBody() []byte

func (*MsgBody) JSON

func (m *MsgBody) JSON() []byte

type Response

type Response struct {
	Type string      `json:"type"`
	Body interface{} `json:"body"`
}

Jump to

Keyboard shortcuts

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