messaging

package
v0.0.0-...-4f87603 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleMessage

func HandleMessage(c *Client, input map[string]string)

func HandleNewConnection

func HandleNewConnection(w http.ResponseWriter, r *http.Request)

Types

type Client

type Client struct {
	ID       int `json:"id"`
	Username string
	Socket   *websocket.Conn
}

func (*Client) Listen

func (c *Client) Listen()

Listens for inbound messages.

type Hub

type Hub struct {
	// Register requests from clients.
	Register chan *Client

	// Unregister requests from clients.
	Unregister chan *Client

	// Handle inbound messages.
	ReadMessage chan *Message

	// Handle outbound messages.
	WriteMessage chan *Message
}

Primary message handler.

func NewHub

func NewHub() *Hub

type Message

type Message struct {
	SenderID int    `json:"senderID"`
	Username string `json:"username"`
	Action   string `json:"action"`
	Body     string `json:"body"`
}

func (*Message) Broadcast

func (m *Message) Broadcast()

func (*Message) BroadcastTo

func (m *Message) BroadcastTo(client *Client)

Jump to

Keyboard shortcuts

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