2022-11-11 12:15:36 +00:00
|
|
|
package gameUtils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ConvertServerSessionsToJSON(s Session) []byte {
|
|
|
|
s_json, err := json.Marshal(s)
|
|
|
|
_ = err //TODO: Check Errors
|
|
|
|
return s_json
|
|
|
|
}
|
|
|
|
|
2022-11-11 12:30:08 +00:00
|
|
|
func FindSessionByID(sessionId string, sessions []Session) Session {
|
|
|
|
for _, session := range sessions {
|
|
|
|
if session.SessionId == sessionId {
|
|
|
|
return session
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Session{ //TODO: Return Errors
|
|
|
|
SessionId: sessionId,
|
|
|
|
GameId: "",
|
|
|
|
Assets: GameInterfaceAssets{},
|
|
|
|
Expires: time.Time{},
|
|
|
|
Arguments: []Argument{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-11 12:15:36 +00:00
|
|
|
var FakeSessions = Sessions{
|
|
|
|
Sessions: []Session{
|
|
|
|
{
|
|
|
|
GameId: "garrysmod",
|
|
|
|
SessionId: "gmod-test",
|
2022-11-11 12:30:08 +00:00
|
|
|
// Icon: "",
|
|
|
|
// Title: "Regular Skirda Gmod server",
|
|
|
|
// Status: "Super fake session",
|
|
|
|
// Version: "",
|
|
|
|
Expires: time.Time{},
|
2022-11-11 12:15:36 +00:00
|
|
|
Arguments: []Argument{
|
|
|
|
{
|
|
|
|
Body: "+connect",
|
|
|
|
Value: "127.0.0.1:27015",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-11 12:30:08 +00:00
|
|
|
// GameId: "half-lide-1",
|
|
|
|
// Title: "Half-Life 1 МЯСО",
|
|
|
|
// Status: "Retro shit",
|
2022-11-11 12:15:36 +00:00
|
|
|
Expires: time.Time{},
|
|
|
|
},
|
|
|
|
{
|
2022-11-11 12:30:08 +00:00
|
|
|
GameId: "minecraft",
|
|
|
|
// Title: "Test 3",
|
|
|
|
// Status: "Testing session",
|
|
|
|
// Version: "1.54.7",
|
2022-11-11 12:15:36 +00:00
|
|
|
Expires: time.Time{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|