websocket

package
v0.0.0-...-211e480 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 4 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 {
	ID   string
	Hub  *Hub
	Conn *gws.Conn
	Send chan Message
}

func NewClient

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

func (*Client) MessageListener

func (c *Client) MessageListener()

func (*Client) WriteMessage

func (c *Client) WriteMessage()

type Hub

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

func NewHub

func NewHub(id string) *Hub

func (*Hub) Run

func (h *Hub) Run(hubs map[string]*Hub)

type Message

type Message struct {
	ID      string      `json:"id"`
	RoomID  string      `json:"roomId"`
	UserID  string      `json:"userId"`
	Content MessageData `json:"content"`
}

func NewMessage

func NewMessage(roomId, userId string, content MessageData) Message

type MessageData

type MessageData struct {
	Datetime time.Time `json:"datetime"`
	Message  string    `json:"message"`
}

func NewMessageData

func NewMessageData(message string) MessageData

Jump to

Keyboard shortcuts

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