Documentation
¶
Index ¶
- type Checklist
- func (c *Checklist) AddItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (c *Checklist) CheckDone() bool
- func (c *Checklist) CheckDoneHTTP(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (c *Checklist) DeleteItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (c *Checklist) GetChecklist(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (c *Checklist) ResetChecklist()
- func (c *Checklist) ToggleItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- type Controller
- func (c Controller) LogError(action string, err error, sendToClient bool)
- func (c Controller) Response(res, err string, code int, w http.ResponseWriter)
- func (c Controller) SendInitialData() []byte
- func (c *Controller) UpdateActiveRuns()
- func (c *Controller) UpdateUpNext()
- func (c Controller) WSChecklistUpdate()
- func (c Controller) WSCurrentUpdate()
- func (c Controller) WSDonationUpdate(oldAmount, newAmount float64)
- func (c Controller) WSReportError(e string)
- func (c Controller) WSRunUpdate()
- func (c Controller) WSRunsOnlyUpdate()
- func (c Controller) WSSettingUpdate()
- func (c Controller) WSStateUpdate()
- func (c Controller) WSTimeUpdate()
- func (c Controller) WSUpNextUpdate()
- type Settings
- type SettingsProvider
- type TimerState
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) 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 ¶
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 ¶
func (s *SettingsProvider) GetSettings(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
GetSettings returns all settings
func (*SettingsProvider) SetSettings ¶
func (s *SettingsProvider) SetSettings(_ http.ResponseWriter, r *http.Request, _ httprouter.Params)
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 )