ws

package
v0.0.0-...-2e7418b Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 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 {
	Conn     *websocket.Conn
	Message  chan *Message
	ID       string `json:"id"`
	RoomID   string `json:"roomId"`
	Username string `json:"username"`
}

type ClientRes

type ClientRes struct {
	ID       string `json:"id"`
	Username string `json:"username"`
}

type CreateRoomReq

type CreateRoomReq struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Handler

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

func NewHandler

func NewHandler(h *Hub) *Handler

func (*Handler) CreateRoom

func (h *Handler) CreateRoom(c *gin.Context)

func (*Handler) GetClients

func (h *Handler) GetClients(c *gin.Context)

func (*Handler) GetRooms

func (h *Handler) GetRooms(c *gin.Context)

func (*Handler) JoinRoom

func (h *Handler) JoinRoom(c *gin.Context)

type Hub

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

func NewHub

func NewHub() *Hub

func (*Hub) Run

func (h *Hub) Run()

type Message

type Message struct {
	Content  string `json:"content"`
	RoomID   string `json:"roomId"`
	Username string `json:"username"`
}

type Room

type Room struct {
	ID      string             `json:"id"`
	Name    string             `json:"name"`
	Clients map[string]*Client `json:"clients"`
}

type RoomRes

type RoomRes struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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