rstructs

package
v0.0.0-...-18b333a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastMessageRes

type BroadcastMessageRes struct {
	Cmd  string                  `json:"cmd"`
	Data BroadcastMessageResData `json:"data"`
}

type BroadcastMessageResData

type BroadcastMessageResData struct {
	RoomID   string `json:"room_id"`
	UserID   string `json:"user_id"`
	Username string `json:"username"`
	Content  string `json:"content"`
}

type JoinedUser

type JoinedUser struct {
	UserID          string `json:"user_id"`
	Username        string `json:"username"`
	PublicKeyString string `json:"public_key_string"`
}

type Room

type Room struct {
	ID              string           `json:"room_id"`
	OwnerID         string           `json:"owner_id"`
	Name            string           `json:"name"`
	OneTimeJoinKeys []string         `json:"one_time_join_keys"`
	ForeverJoinKey  string           `json:"forever_join_key"`
	Users           map[string]*User `json:"users"`
}

func NewRoom

func NewRoom(name, ownerID string) *Room

func (*Room) AddUser

func (r *Room) AddUser(u *User)

AddUser adds a userID to a room if it isn't already there. This allows the user to receive messages from the room.

func (*Room) BroadcastMessage

func (r *Room) BroadcastMessage(userID, content string)

func (*Room) GetUsers

func (r *Room) GetUsers() []JoinedUser

func (*Room) HasUser

func (r *Room) HasUser(userID string) bool

type State

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

func NewState

func NewState() *State

func (*State) AddRoom

func (s *State) AddRoom(room *Room)

func (*State) CleanupRooms

func (s *State) CleanupRooms(userID string)

func (*State) CreateOneTimeRoomKey

func (s *State) CreateOneTimeRoomKey(id string) string

func (*State) HasRoom

func (s *State) HasRoom(id string) bool

type User

type User struct {
	Conn            *websocket.Conn
	UserID          string
	Username        string
	PublicKey       *rsa.PublicKey
	PublicKeyString string
}

Jump to

Keyboard shortcuts

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