common

package
v0.0.0-...-519d529 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checklist

type Checklist struct {
	Items []*item
	// we need to access this at some crucial times like timer start. we can't afford the time it takes for the loop to finish processing then
	// that's why we set this variable with every call to add, remove and toggle so this variable will only have to be accessed to see if the checklist is done
	Finished bool
	// contains filtered or unexported fields
}

Checklist provides the implementation of a checklist

func NewChecklist

func NewChecklist(b *Controller) *Checklist

NewChecklist initializes and returns a new Checklist

func (*Checklist) AddItem

func (c *Checklist) AddItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

AddItem will add an item to the checklist

func (*Checklist) CheckDone

func (c *Checklist) CheckDone() bool

CheckDone will return whether all the items in the checklist are done

func (*Checklist) CheckDoneHTTP

func (c *Checklist) CheckDoneHTTP(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

CheckDoneHTTP will return whether all the items in the checklist are done

func (*Checklist) DeleteItem

func (c *Checklist) DeleteItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

DeleteItem will delete an item from the checklist

func (*Checklist) GetChecklist

func (c *Checklist) GetChecklist(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

GetChecklist will get all items from the checklist

func (*Checklist) ResetChecklist

func (c *Checklist) ResetChecklist()

func (*Checklist) ToggleItem

func (c *Checklist) ToggleItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

ToggleItem will toggle the status of an item if it exists

type Controller

type Controller struct {
	WS          *ws.Hub
	MGS         *mgo.Session
	Col         *mgo.Collection
	RunIndex    int
	CurrentRun  *models.Run
	NextRun     *models.Run
	PrevRun     *models.Run
	UpNext      *models.Run
	RedisClient *redis.Client
	TimerState  TimerState
	TimerTime   float64
	HTTPClient  http.Client
	// SocialUpdatesChan is used to communicate with the socialController on Twitter and twitch updates
	SocialUpdatesChan chan int
	CL                *Checklist
	Settings          *SettingsProvider
}

Controller is the base struct for any controller. It's used to manage state and other things.

func NewController

func NewController(hub *ws.Hub, mgs *mgo.Session, crIndex int, rc *redis.Client) *Controller

NewController returns a new base controller

func (Controller) LogError

func (c Controller) LogError(action string, err error, sendToClient bool)

LogError is a helper function to log any errors and send a message informing the client about the error over websocket if wanted

func (Controller) Response

func (c Controller) Response(res, err string, code int, w http.ResponseWriter)

Response will send out a generic response

func (Controller) SendInitialData

func (c Controller) SendInitialData() []byte

SendInitialData will send some initial data over the websocket

func (*Controller) UpdateActiveRuns

func (c *Controller) UpdateActiveRuns()

UpdateActiveRuns will update the the previous, current and next run in the base controller struct

func (*Controller) UpdateUpNext

func (c *Controller) UpdateUpNext()

UpdateUpNext will set the UpNext field on the base controller object to next run. That means NextRun und UpNext can be updated at different times. For displaying up next in overlay

func (Controller) WSChecklistUpdate

func (c Controller) WSChecklistUpdate()

WSChecklistUpdate sends a checklist update to the websocket

func (Controller) WSCurrentUpdate

func (c Controller) WSCurrentUpdate()

WSCurrentUpdate sends ws data with the current runs

func (Controller) WSDonationUpdate

func (c Controller) WSDonationUpdate(oldAmount, newAmount float64)

WSDonationUpdate sends an update about donations to the client

func (Controller) WSReportError

func (c Controller) WSReportError(e string)

WSReportError provides a helper to send an error message to the client

func (Controller) WSRunUpdate

func (c Controller) WSRunUpdate()

WSRunUpdate sends an update for all runs over the websocket and current runs over the websocket.

func (Controller) WSRunsOnlyUpdate

func (c Controller) WSRunsOnlyUpdate()

WSRunsOnlyUpdate only updates runs and not current runs

func (Controller) WSSettingUpdate

func (c Controller) WSSettingUpdate()

WSSettingUpdate sends a settings update

func (Controller) WSStateUpdate

func (c Controller) WSStateUpdate()

WSStateUpdate sends a state update

func (Controller) WSTimeUpdate

func (c Controller) WSTimeUpdate()

WSTimeUpdate sends a time update

func (Controller) WSUpNextUpdate

func (c Controller) WSUpNextUpdate()

WSUpNextUpdate will set the up next run

type Settings

type Settings struct {
	Currency            string `json:"currency"`
	Chat                string `json:"chat"`
	SocialCircleTime    int    `json:"socialCircleTime"`
	TwitchUpdateChannel string `json:"twitchUpdateChannel"`
}

Settings provides just some general settings

type SettingsProvider

type SettingsProvider struct {
	S *Settings
	// contains filtered or unexported fields
}

SettingsProvider provides something idk

func InitSettings

func InitSettings(b *Controller) *SettingsProvider

InitSettings will return a SettingsProvider

func (*SettingsProvider) GetSettings

GetSettings returns all settings

func (*SettingsProvider) SetSettings

SetSettings is used to set the settings

type TimerState

type TimerState = int

TimerState is an alias of int to represent timer state

const (
	// TimerRunning represents a running timer
	TimerRunning TimerState = iota
	// TimerPaused represents a paused timer
	TimerPaused
	// TimerStopped represents a stopped timer
	TimerStopped
	// TimerFinished represents a finished timer
	TimerFinished
)

Jump to

Keyboard shortcuts

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