ws

package
v0.0.0-...-80b2b3e Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 11 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 {
	// contains filtered or unexported fields
}

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

func NewClient

func NewClient(hub *Hub, conn *websocket.Conn) *Client

func (*Client) Close

func (cl *Client) Close()

Close will close send channel and connection once

type Hub

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

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

func NewHub

func NewHub() *Hub

func (*Hub) Broadcast

func (h *Hub) Broadcast(msg models.MessageInterface) error

func (*Hub) GetUpgrader

func (h *Hub) GetUpgrader() *websocket.Upgrader

func (*Hub) GracefulStop

func (h *Hub) GracefulStop(ctx context.Context) error

TODO GracefulStop shuts down the socket.

func (*Hub) RegisterClient

func (h *Hub) RegisterClient(conn *websocket.Conn)

func (*Hub) Run

func (h *Hub) Run()

func (*Hub) Title

func (h *Hub) Title() string

Title returns the title.

type HubInterface

type HubInterface interface {
	RegisterClient(*websocket.Conn)
	Broadcast(...interface{}) error
}

type PublicMsg

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

type UserMsg

type UserMsg struct {
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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