44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package sessionUtils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
|
|
gamesModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/games"
|
|
sessionsModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/sessions"
|
|
)
|
|
|
|
func ConvertServerSessionsToJSON(s sessionsModels.Session) []byte {
|
|
s_json, err := json.Marshal(s)
|
|
_ = err //TODO: Check Errors
|
|
return s_json
|
|
}
|
|
|
|
func FindSessionByID(sessionId string, sessions []sessionsModels.Session) sessionsModels.Session {
|
|
for _, session := range sessions {
|
|
if session.SessionId == sessionId {
|
|
return session
|
|
}
|
|
}
|
|
return sessionsModels.Session{ //TODO: Return Errors
|
|
SessionId: sessionId,
|
|
GameId: "",
|
|
Assets: gamesModels.GameInterfaceAssets{},
|
|
Expires: time.Time{},
|
|
Arguments: []gamesModels.Argument{},
|
|
}
|
|
}
|
|
|
|
func GetJSSessionInterface(s sessionsModels.Session) sessionsModels.JSSessionInterface {
|
|
newInterface := sessionsModels.JSSessionInterface{ //TODO: If session icon empty - use game icon
|
|
GameID: s.GameId,
|
|
SessionId: s.SessionId,
|
|
Expires: time.Time{},
|
|
Title: s.Assets.Title,
|
|
Icon: s.Assets.Icon,
|
|
Description: s.Assets.Description,
|
|
Backgrounds: []string{}, //TODO: Complete
|
|
}
|
|
return newInterface
|
|
}
|