client

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: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoomKeyTypeOneTime = iota
	RoomKeyTypeForever
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CRoom

type CRoom struct {
	ClientRoomID string
	Client       *Client

	IsOwner     bool
	ReqName     string
	ReqUsername string

	Room         *rstructs.Room
	MessageQueue []string
	// contains filtered or unexported fields
}

func (*CRoom) AddJoinedUser

func (r *CRoom) AddJoinedUser(userID, username, pubKey string)

func (*CRoom) GetKey

func (r *CRoom) GetKey(t string) error

func (*CRoom) On

func (r *CRoom) On(name string, cb interface{})

func (*CRoom) SendMessage

func (r *CRoom) SendMessage(content string) error

func (*CRoom) UpdateUsers

func (r *CRoom) UpdateUsers(users []rstructs.JoinedUser)

type Client

type Client struct {
	Host string
	Path string

	UserID string

	// when user creates room, we add CRoom to RoomQueue. When Rooms is filled,
	// we'll update the CRoom's reference to Room
	Rooms     []*CRoom // rooms the user is in. key is the room id
	RoomQueue []*CRoom

	Conn *websocket.Conn

	PrivateKey *rsa.PrivateKey
}

func NewClient

func NewClient(path, host string, tlsConf *tls.Config) (*Client, error)

func (*Client) CreateRoom

func (c *Client) CreateRoom(name, username, clientRoomID string) *CRoom

func (*Client) JoinRoom

func (c *Client) JoinRoom(keyType, username, roomID, key string) (*CRoom, error)

func (*Client) Listen

func (c *Client) Listen()

Jump to

Keyboard shortcuts

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