ws

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MulanPSL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConn

func NewConn(w http.ResponseWriter, r *http.Request) (conn *websocket.Conn, err error)

Types

type Client

type Client struct {
	Id     string
	Groups []string
	Hub    *Hub
	Conn   *websocket.Conn
	Send   chan *Message
}

func NewClient

func NewClient(hub *Hub, conn *websocket.Conn, uid string, groups []string, fr, fw func(*Client, *Message) error) *Client

type Hub

type Hub struct {
	Clients    map[string]*Client
	Broadcast  chan *Message
	Register   chan *Client
	Unregister chan *Client
}

func NewHub

func NewHub(fn, fu func(*Client), fb func(*Message) error) *Hub

type Message

type Message struct {
	Sender     string   `json:"sender,omitempty"`
	Recipients []string `json:"recipients,omitempty"`
	Groups     []string `json:"groups,omitempty"`
	Content    any      `json:"content,omitempty"`
}

Jump to

Keyboard shortcuts

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