64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package sharedUtils
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type SkirdaSessions []SkirdaSession
|
|
|
|
func (sessions SkirdaSessions) FindSessionById(sessionId string) (SkirdaSession, error) {
|
|
for _, session := range sessions {
|
|
if session.GetSessionId() == sessionId {
|
|
return session, nil
|
|
}
|
|
}
|
|
return sessions[0], nil //TODO: Temp error return
|
|
}
|
|
|
|
func (sessions SkirdaSessions) GetInterfaceAssets() []JSSessionInterface {
|
|
assets := []JSSessionInterface{}
|
|
|
|
for _, session := range sessions {
|
|
assets = append(assets, session.GetInterfaceAsset())
|
|
}
|
|
return assets
|
|
}
|
|
|
|
type SkirdaSession struct {
|
|
SkirdaSessionId string
|
|
SkirdaGameId string
|
|
Args []string
|
|
NegativeArgs []string
|
|
}
|
|
|
|
type JSSessionInterface struct {
|
|
GameID string `json:"gameId"`
|
|
SessionId string `json:"sessionId"`
|
|
Expires time.Time `json:"expires"`
|
|
Title string `json:"title"`
|
|
Icon string `json:"icon"`
|
|
Description string `json:"description"`
|
|
Backgrounds []string `json:"backgrounds"`
|
|
}
|
|
|
|
func (session SkirdaSession) GetSessionId() string {
|
|
return session.SkirdaSessionId
|
|
}
|
|
|
|
func (session SkirdaSession) GetGameId() string {
|
|
return session.SkirdaGameId
|
|
}
|
|
|
|
func (session SkirdaSession) GetInterfaceAsset() JSSessionInterface {
|
|
// gameId := SkirdaGame.GetSkirdaGameId()
|
|
return JSSessionInterface{
|
|
GameID: "",
|
|
SessionId: "",
|
|
Expires: time.Time{},
|
|
Title: "Test Session",
|
|
Icon: "",
|
|
Description: "",
|
|
Backgrounds: []string{},
|
|
}
|
|
}
|