websocket

package
v0.0.0-...-9812ac9 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)

Types

type Client

type Client struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Conn *websocket.Conn
	Room *Room
}

func (*Client) Read

func (c *Client) Read()

type Message

type Message struct {
	Type int    `json:"type"`
	Body string `json:"body"`
	User string `json:"user"`
	Room string `json:"room"`
}

type Pool

type Pool struct {
	Rooms map[string]*Room
}

func InitPools

func InitPools() *Pool

type Room

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

func NewRoom

func NewRoom(id string) *Room

func (*Room) Start

func (room *Room) Start(pool *Pool)

Jump to

Keyboard shortcuts

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