sharedutils/domain/skirdasession.go

129 lines
2.7 KiB
Go
Raw Normal View History

2023-02-12 16:58:39 +00:00
package domain
2023-01-24 13:46:17 +00:00
import (
"errors"
)
type SkirdaSession interface {
GetSessionId() string
GetGameId() string
GetUIAssets() SessionUIAssets
GetGameType() string
GetSessionData() string
}
// type SkirdaSession struct {
// SkirdaSessionId string
// SkirdaGameId string
// Assets SessionUIAssets
// }
type SkirdaSessions []SkirdaSession
2023-02-01 19:56:35 +00:00
// GetGameId implements SkirdaSession
func (SkirdaSessions) GetGameId() string {
panic("unimplemented")
}
// GetGameType implements SkirdaSession
func (SkirdaSessions) GetGameType() string {
panic("unimplemented")
}
// GetSessionData implements SkirdaSession
func (SkirdaSessions) GetSessionData() string {
panic("unimplemented")
}
// GetSessionId implements SkirdaSession
func (SkirdaSessions) GetSessionId() string {
panic("unimplemented")
}
// GetUIAssets implements SkirdaSession
func (SkirdaSessions) GetUIAssets() SessionUIAssets {
panic("unimplemented")
}
2023-01-24 13:46:17 +00:00
type SessionUIAssets struct {
// GameID string `json:"gameId"`
Title string `json:"title"`
Icon string `json:"icon"`
Description string `json:"description"`
}
func (sessions SkirdaSessions) FindSessionById(sessionId string) (SkirdaSession, error) {
for _, session := range sessions {
if session.GetSessionId() == sessionId {
return session, nil
}
}
return nil, errors.New("no any sessions founded")
}
func (sessions SkirdaSessions) AddSessions(newSessions []SkirdaSession) {
sessions = append(sessions, newSessions...)
}
type MinecraftSession struct {
SkirdaSessionId string
SkirdaGameId string
Assets SessionUIAssets
Version string
}
func (session MinecraftSession) GetSessionId() string {
return session.SkirdaSessionId
}
func (session MinecraftSession) GetUIAssets() SessionUIAssets {
return session.Assets
}
func (session MinecraftSession) GetGameId() string {
return session.SkirdaGameId
}
func (session MinecraftSession) GetMinecraftVersion() string {
return session.SkirdaGameId
}
func (session MinecraftSession) GetGameType() string {
return "minecraft"
}
func (session MinecraftSession) GetSessionData() string {
return session.Version
}
type SteamSession struct {
SkirdaSessionId string
SkirdaGameId string
Assets SessionUIAssets
// Data SteamSessionData
}
type SteamSessionData struct {
kke string
}
func (session SteamSession) GetSessionId() string {
return session.SkirdaSessionId
}
func (session SteamSession) GetUIAssets() SessionUIAssets {
return session.Assets
}
func (session SteamSession) GetGameId() string {
return session.SkirdaGameId
}
func (session SteamSession) GetGameType() string {
return "steam"
}
func (session SteamSession) GetSessionData() string {
return ""
}