ws

package
v0.0.0-...-db5c55e Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: AGPL-3.0-or-later Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UserCache is the list of users currently with ws connections to this instance
	UserCache = map[dbt.UUID]*User{}
)

Functions

func AllOnlineIDs

func AllOnlineIDs() []string

AllOnlineIDs returns ULID of every online user

func BroadcastMessage

func BroadcastMessage(message map[string]interface{})

BroadcastMessage sends message to all users

func BroadcastMessageRaw

func BroadcastMessageRaw(message *fastjson.Value)

func Close

func Close()

Close disconnect all remaining users

func OnlineUserCount

func OnlineUserCount() int64

OnlineUserCount is the total number of active users

Types

type User

type User struct {
	User *db.User
	// contains filtered or unexported fields
}

func Connect

func Connect(user *db.User, w http.ResponseWriter, r *http.Request) (*User, error)

Connect takes a db.User and upgrades it to a ws.User

func (*User) Disconnect

func (u *User) Disconnect()

func (*User) IsConnected

func (u *User) IsConnected() bool

func (*User) ReadMessage

func (u *User) ReadMessage() (int, []byte, error)

func (*User) SendMessage

func (u *User) SendMessage(in *db.Channel, msg string)

func (*User) SendWsMessage

func (u *User) SendWsMessage(msg map[string]interface{})

func (*User) SendWsMessageRaw

func (u *User) SendWsMessageRaw(msg []byte)

type UserPerms

type UserPerms struct {
	ManageChannels bool `json:"manage_channels"`
	ManageRoles    bool `json:"manage_roles"`
	ManageServer   bool `json:"manage_server"`
	ManageInvites  bool `json:"manage_invites"`
	ViewAudits     bool `json:"view_audits"`
	ManageBans     bool `json:"manage_bans"`
}

func (UserPerms) From

func (v UserPerms) From(user *db.User) *UserPerms

From calculates a user's permissions based on the roles they have

Jump to

Keyboard shortcuts

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