chc

package module
v0.0.0-...-a66781c Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InitRoom

type InitRoom struct {
	// creating ? Name : Token
	Data     string `json:"d"`
	Password string
}

type Message

type Message struct {
	// The type of the message:
	//  1 (welcome)
	//  100 (text message)
	//  200 (create room), 210 (user join), 211 (user leave),
	//    212 (delete room)
	//  300 (status change)
	//  400 (ok), 401 (unauthorized), 404 (not found)
	Type int `json:"op"`

	Data interface{} `json:"d"`

	Token  string `json:"tkn"`
	RoomID string `json:"rid"`
}

Message is a JSON packet sent both by the server and clients. See Type.

type Room

type Room struct {
	// The room's name formatted to be
	// valid in a URL.
	ID string

	Name     string
	Password string

	// The room owner's ID.
	OwnerID string

	// This is a map of IDs so users can easily
	// be fetched.
	Users map[string]*User `json:"-"`
}

type User

type User struct {
	// The user's connection to the websocket.
	Conn *websocket.Conn `json:"-"`

	Token string
	Name  string

	// All the IDs of rooms this user is a part of.
	Rooms []string
}

Jump to

Keyboard shortcuts

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