cache

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2019 License: LGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MoveNormal = iota
	MoveHead
	MoveError
)

Variables

View Source
var (
	// ErrUnsupportedFormat return when link to unsupported video format was received
	ErrUnsupportedFormat = errors.New("Unsupported video format. Support only .mp4, .m3u8, .webm")

	// ErrVideoNotFound return when video by specified ID was not found
	ErrVideoNotFound = errors.New("Video with this ID was not found")

	// ErrEmptyYoutubeVideoID return when youtube video id (v param in link) is empty
	ErrEmptyYoutubeVideoID = errors.New("Youtube video ID is empty")

	// ErrUnsupportedHost return when video link has unsupported host
	ErrUnsupportedHost = errors.New("Unsupported host")

	// ErrLinkDoesNotMath return when regexp check return false, but host is supported
	ErrLinkDoesNotMath = errors.New("Link does't match required format")
)

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Users    Users
	Playlist playlist
	Messages Messages
	Room     Room
	ID       string
	Close    chan struct{}
}

Cache is storage of users and playlist for a room

func New

func New(id string) *Cache

New create new cache

func (*Cache) HandleCacheEvents

func (cache *Cache) HandleCacheEvents()

HandleCacheEvents handle cache event one at time

type Message

type Message struct {
	Message string
	Name    string
	Color   string
	Image   string
	ID      string
	Guest   bool
}

type Messages

type Messages struct {
	AddMessage chan Message
	// contains filtered or unexported fields
}

func (Messages) GetAllMessages

func (m Messages) GetAllMessages() []Message

GetAllMessages return all cache maxMessageStorageSize messages

func (Messages) Size

func (m Messages) Size() int

Size return size of cached messages

type MoveVideo

type MoveVideo struct {
	ID    string
	Index int
}

MoveVideo object for moving video

type NewRole

type NewRole struct {
	ID    string
	Level int
}

type NewVideo

type NewVideo struct {
	URL           string
	Subtitles     string
	SubtitlesURL  string
	SubtitlesType string
}

NewVideo a new video object. Has url and options subtitles

type Room

type Room struct {
	UpdateEmojis                  chan string
	UpdatePermissions             chan struct{}
	UpdateRoles                   chan string
	UpdateSubtitlesOffset         chan int
	UpdateSubtitlesOffsetFeedBack chan int
	Permissions                   map[string]int
	SubtitlesOffset               int
	Roles                         []db.Role
	// contains filtered or unexported fields
}

func (Room) CheckPermissions

func (room Room) CheckPermissions(eType, uuid string, payload *jwt.Payload) bool

CheckPermissions check a user permissions for eType action and return result

type User

type User struct {
	Name    string       `json:"name"`
	Color   string       `json:"color,omitempty"`
	Image   string       `json:"image,omitempty"`
	Guest   bool         `json:"guest"`
	Payload *jwt.Payload `json:"-"`
	UUID    string       `json:"uuid,omitempty"`
	ID      string       `json:"__id"`
}

User is single user instance

type Users

type Users struct {
	AddUser     chan *jwt.Payload
	AddGuest    chan *User
	UpdateRole  chan NewRole
	DelUser     chan string
	DelFeedback chan struct{}
	UpdateUsers chan struct{}
	// contains filtered or unexported fields
}

Users is users storage and channels for adding/removing

func (Users) GetAllUsers

func (u Users) GetAllUsers() []*User

GetAllUsers return all users

func (Users) GetUUIDByID

func (u Users) GetUUIDByID(id string) string

GetUUIDByID return user UUID by ID

func (Users) GetUserByUUID

func (u Users) GetUserByUUID(uuid string) (*User, bool)

GetUserByUUID return user object by UUID

func (*Users) UpdateUser

func (u *Users) UpdateUser(uuid string)

UpdateUser update user in cache, image, nickname, color etc.

func (Users) UsersCount

func (u Users) UsersCount() int

UsersCount return count users for current room

type Video

type Video struct {
	Title      string `json:"title"`
	Duration   int    `json:"duration"`
	URL        string `json:"url"`
	Direct     bool   `json:"direct"`
	Subtitles  string `json:"subs,omitempty"`
	Iframe     bool   `json:"iframe"`
	LiveStream bool   `json:"live_stream"`
	ID         string `json:"__id"`
}

Video is instance of a video in playlist

Jump to

Keyboard shortcuts

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