session

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PauseTimerChannel = make(chan PauseRequest)

PauseTimerChannel reads pause requests as they come in via pauseSessionEndpoint

View Source
var Sessions []Session

Sessions is a collection of all current sessions

View Source
var UnpauseTimerChannel = make(chan UnpauseRequest)

UnpauseTimerChannel reads restart requests as they come in via unpauseSessionEndpoint

View Source
var UpdateTimerChannel = make(chan UpdateRequest)

UpdateTimerChannel reads updates as they come in via updateSessionEndpoint

Functions

func AddUserConnToSession

func AddUserConnToSession(uuid string, conn *websocket.Conn) error

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

func HandleRemoveUser(conn *websocket.Conn) error

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

func RemoveSession(sessionID string) error

RemoveSession ... for a abandoned session

Types

type Connector

type Connector interface {
	WriteJSON(v interface{}) error
	ReadMessage() (int, []byte, error)
}

Connector is .. the User's current connection

type ExistingSessionReq

type ExistingSessionReq struct {
	JoinSessionID string `json:"joinSession"`
}

ExistingSessionReq ... join an existing session http request

type InitSessionResponse

type InitSessionResponse struct {
	Session Session
	User    User
}

InitSessionResponse is ... on inital connection

type PauseRequest added in v1.1.0

type PauseRequest struct {
	SessionID string `json:"sessionId"`
	PauseTime int64  `json:"pauseTime"`
}

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

type StartTimerReq struct {
	Duration  int64 `json:"duration"`
	StartTime int64 `json:"startTime"`
}

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)

type User

type User struct {
	UUID string
	Conn Connector
}

User is ... each connected user

Jump to

Keyboard shortcuts

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