Documentation ¶
Index ¶
- Variables
- func AddUserConnToSession(uuid string, conn *websocket.Conn) error
- func HandlePauseSession(sessionToPause PauseRequest)
- func HandleRemoveUser(conn *websocket.Conn) error
- func HandleUnpauseSession(sessionToUnpause UnpauseRequest)
- func HandleUpdateSession(sessionToUpdate UpdateRequest)
- func RemoveSession(sessionID string) error
- type Connector
- type ExistingSessionReq
- type InitSessionResponse
- type PauseRequest
- type PauseSessionResponse
- type Session
- type StartTimerReq
- type UnpauseRequest
- type UnpauseSessionResponse
- type UpdateRequest
- type User
Constants ¶
This section is empty.
Variables ¶
var PauseTimerChannel = make(chan PauseRequest)
PauseTimerChannel reads pause requests as they come in via pauseSessionEndpoint
var Sessions []Session
Sessions is a collection of all current sessions
var UnpauseTimerChannel = make(chan UnpauseRequest)
UnpauseTimerChannel reads restart requests as they come in via unpauseSessionEndpoint
var UpdateTimerChannel = make(chan UpdateRequest)
UpdateTimerChannel reads updates as they come in via updateSessionEndpoint
Functions ¶
func AddUserConnToSession ¶
AddUserConnToSession adds the ws connection to the relevant session
func HandlePauseSession ¶ added in v1.1.0
func HandlePauseSession(sessionToPause PauseRequest)
HandlePauseSession when the driver pauses the timer
func HandleRemoveUser ¶
HandleRemoveUser ... of a disconneted user from the relevent session
func HandleUnpauseSession ¶ added in v1.1.0
func HandleUnpauseSession(sessionToUnpause UnpauseRequest)
HandleUnpauseSession when the driver pauses the timer
func HandleUpdateSession ¶
func HandleUpdateSession(sessionToUpdate UpdateRequest)
HandleUpdateSession when a timer finishes
func RemoveSession ¶
RemoveSession ... for a abandoned session
Types ¶
type ExistingSessionReq ¶
type ExistingSessionReq struct {
JoinSessionID string `json:"joinSession"`
}
ExistingSessionReq ... join an existing session http request
type InitSessionResponse ¶
InitSessionResponse is ... on inital connection
type PauseRequest ¶ added in v1.1.0
PauseRequest ... incoming pause time and session ID from client
type PauseSessionResponse ¶ added in v1.1.0
type PauseSessionResponse struct {
PauseTime int64
}
PauseSessionResponse ... the time when a user pauses the timer
type Session ¶
type Session struct { SessionID string CurrentDriver User Duration int64 StartTime int64 EndTime int64 PreviousDrivers []User Users []User }
Session is ... each active session
func CreateNewUserAndSession ¶
func CreateNewUserAndSession( newSessionData StartTimerReq, newUser User, generateIDFunc utils.RandomGenerator, ) Session
CreateNewUserAndSession creates new users and sessions
func JoinExistingSession ¶
func JoinExistingSession(joinExistingSessionData ExistingSessionReq, newUser User) (Session, error)
JoinExistingSession adds a user to an existing session
type StartTimerReq ¶
StartTimerReq ... JSON request from the client
type UnpauseRequest ¶ added in v1.1.0
type UnpauseRequest struct { SessionID string `json:"sessionId"` UnpauseTime int64 `json:"unpauseTime"` }
UnpauseRequest ... incoming pause time and session ID from client
type UnpauseSessionResponse ¶ added in v1.1.0
type UnpauseSessionResponse struct {
UnpauseTime int64
}
UnpauseSessionResponse ... the time when a user restarts the timer
type UpdateRequest ¶ added in v1.0.0
type UpdateRequest struct { SessionID string `json:"sessionId"` UpdatedDuration int64 `json:"updatedDuration,omitempty"` }
UpdateRequest .. Incoming timer update from client (current driver)