Documentation ¶
Index ¶
- Constants
- Variables
- func Compress(data []byte) ([]byte, error)
- func EncodeDemo(startTime time.Time, messages []RecordedPacket) ([]byte, error)
- func EncodeSession(startTime time.Time, messages []RecordedPacket) ([]byte, error)
- func RecordSession(ctx context.Context, redis *redis.Client, shouldSave bool, user *User) error
- func WriteFile(path string, data []byte) error
- type Cluster
- func (c *Cluster) AnnounceInServer(ctx context.Context, server *servers.GameServer, message string)
- func (server *Cluster) CreateGame(ctx context.Context, params *CreateParams, user *User) error
- func (server *Cluster) ForwardGlobalChat(ctx context.Context, sender *User, message string)
- func (server *Cluster) GetClientInfo() []*servers.ClientExtInfo
- func (c *Cluster) GetDemo(ctx context.Context, id string) ([]byte, error)
- func (server *Cluster) GetServerInfo() *servers.ServerInfo
- func (server *Cluster) GetTeamInfo() *servers.TeamInfo
- func (server *Cluster) GetUptime() int
- func (server *Cluster) GivePrivateMatchHelp(ctx context.Context, user *User, gameServer *servers.GameServer)
- func (server *Cluster) GreetClient(ctx context.Context, user *User)
- func (s *Cluster) HandleCommand(ctx context.Context, user *User, command string)
- func (c *Cluster) HandleTeleport(ctx context.Context, user *User, source int32)
- func (server *Cluster) NotifyClientChange(ctx context.Context, user *User, joined bool)
- func (c *Cluster) NotifyNameChange(ctx context.Context, user *User, name string)
- func (server *Cluster) PollDuels(ctx context.Context)
- func (c *Cluster) PollFromMessages(ctx context.Context, user *User)
- func (server *Cluster) PollServers(ctx context.Context)
- func (c *Cluster) PollToMessages(ctx context.Context, user *User)
- func (c *Cluster) PollUser(ctx context.Context, user *User)
- func (server *Cluster) PollUsers(ctx context.Context, newConnections chan ingress.Connection)
- func (c *Cluster) SendMap(ctx context.Context, user *User, name string) error
- func (c *Cluster) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (server *Cluster) Shutdown()
- func (server *Cluster) StartServers(ctx context.Context)
- type ConnectionEvent
- type CreateParams
- type Duel
- func (d *Duel) Cleanup()
- func (d *Duel) Logger() zerolog.Logger
- func (d *Duel) MonitorClient(ctx context.Context, user *User, oldServer *servers.GameServer, ...)
- func (d *Duel) PollDeaths(ctx context.Context)
- func (d *Duel) Respawn(ctx context.Context, user *User)
- func (d *Duel) Run(ctx context.Context)
- type DuelDone
- type DuelPhase
- type DuelQueue
- type DuelResult
- type ELO
- type ELOState
- type Matchmaker
- func (m *Matchmaker) Dequeue(user *User)
- func (m *Matchmaker) FindDuelType(name string) opt.Option[config.DuelType]
- func (m *Matchmaker) NotifyProgress(queued *QueuedClient)
- func (m *Matchmaker) Poll(ctx context.Context)
- func (m *Matchmaker) Queue(user *User, typeName string) error
- func (m *Matchmaker) ReceiveQueues() <-chan DuelQueue
- func (m *Matchmaker) ReceiveResults() <-chan DuelResult
- type QueuedClient
- type RecordedPacket
- type TrackedPacket
- type User
- func (u *User) AnnounceELO()
- func (u *User) Connect(server *servers.GameServer) (<-chan bool, error)
- func (u *User) ConnectToServer(server *servers.GameServer, target string, shouldCopy bool, isSpace bool) (<-chan bool, error)
- func (u *User) ConnectToSpace(server *servers.GameServer, id string) (<-chan bool, error)
- func (c *User) DelayMessages()
- func (u *User) DisconnectFromServer() error
- func (u *User) GetAutoexecKey() string
- func (u *User) GetClientNum() int
- func (u *User) GetFormattedName() string
- func (u *User) GetFormattedReference() string
- func (u *User) GetName() string
- func (u *User) GetServer() *servers.GameServer
- func (u *User) GetServerInfo() P.ServerInfo
- func (u *User) GetServerName() string
- func (u *User) GetSessionID() string
- func (u *User) GetSpace() *verse.SpaceInstance
- func (c *User) GetStatus() UserStatus
- func (u *User) HasCubeScript() bool
- func (u *User) IsAtHome(ctx context.Context) (bool, error)
- func (u *User) IsInSpace() bool
- func (u *User) Logger() zerolog.Logger
- func (u *User) Message(message string)
- func (u *User) RawMessage(message string)
- func (c *User) ReceiveConnections() <-chan ConnectionEvent
- func (c *User) ReceiveToMessages() <-chan TrackedPacket
- func (u *User) Reference() string
- func (u *User) Response(ctx context.Context, code P.MessageCode, messages ...P.Message) (P.Message, error)
- func (u *User) ResponseTimeout(ctx context.Context, timeout time.Duration, code P.MessageCode, ...) (P.Message, error)
- func (c *User) RestoreMessages()
- func (u *User) RunCubeScript(ctx context.Context, code string) error
- func (c *User) Send(messages ...P.Message) <-chan error
- func (c *User) SendChannel(channel uint8, messages ...P.Message) <-chan error
- func (c *User) SendChannelSync(channel uint8, messages ...P.Message) error
- func (c *User) SendSync(messages ...P.Message) error
- func (u *User) ServerSessionContext() context.Context
- func (u *User) SetName(ctx context.Context, name string)
- type UserOrchestrator
- type UserStatus
Constants ¶
View Source
const ( CONSENT_EXPIRATION = 30 * 24 * time.Hour AUTOEXEC_KEY = "autoexec-%s" )
View Source
const ( DuelPhaseWarmup = iota DuelPhaseBattle DuelPhaseOvertime DuelPhaseDone )
View Source
const ( DEMO_KEY = "demo-%s" DEMO_TTL = time.Duration(48 * time.Hour) )
View Source
const ( UserStatusConnecting = iota UserStatusConnected UserStatusDisconnected )
View Source
const (
CREATE_SERVER_COOLDOWN = time.Duration(10 * time.Second)
)
View Source
const INITIAL_SCRIPT = `` /* 144-byte string literal not displayed */
View Source
const RUN_WAIT_TIMEOUT = 15 * time.Second
View Source
const TUNNEL_MODE = true
Variables ¶
View Source
var (
DEMO_PATH_REGEX = regexp.MustCompile(`^/api/demo/([\w-]+)$`)
)
View Source
var PURGATORY []byte
Functions ¶
func EncodeDemo ¶
func EncodeDemo(startTime time.Time, messages []RecordedPacket) ([]byte, error)
func EncodeSession ¶
func EncodeSession(startTime time.Time, messages []RecordedPacket) ([]byte, error)
func RecordSession ¶
Types ¶
type Cluster ¶
type Cluster struct { // Services Users *UserOrchestrator // contains filtered or unexported fields }
func NewCluster ¶
func NewCluster( ctx context.Context, serverManager *servers.ServerManager, maps *assets.AssetFetcher, settings config.ServerSettings, ) *Cluster
func (*Cluster) AnnounceInServer ¶
func (*Cluster) CreateGame ¶
func (*Cluster) ForwardGlobalChat ¶
func (*Cluster) GetClientInfo ¶
func (server *Cluster) GetClientInfo() []*servers.ClientExtInfo
We need client information, so this is not on the ServerManager like GetServerInfo is
func (*Cluster) GetServerInfo ¶
func (server *Cluster) GetServerInfo() *servers.ServerInfo
func (*Cluster) GetTeamInfo ¶
func (*Cluster) GivePrivateMatchHelp ¶
func (*Cluster) HandleCommand ¶
func (*Cluster) HandleTeleport ¶
func (*Cluster) NotifyClientChange ¶
func (*Cluster) NotifyNameChange ¶
func (*Cluster) PollFromMessages ¶
func (*Cluster) PollServers ¶
func (*Cluster) PollUsers ¶
func (server *Cluster) PollUsers(ctx context.Context, newConnections chan ingress.Connection)
func (*Cluster) StartServers ¶
type ConnectionEvent ¶
type ConnectionEvent struct {
Server *servers.GameServer
}
type CreateParams ¶
type Duel ¶
type Duel struct { Mutex sync.Mutex Phase DuelPhase Type config.DuelType A *User B *User Manager *servers.ServerManager Finished chan DuelDone // contains filtered or unexported fields }
func (*Duel) Cleanup ¶
func (d *Duel) Cleanup()
Free up resources and move clients back to their original servers
func (*Duel) MonitorClient ¶
func (d *Duel) MonitorClient( ctx context.Context, user *User, oldServer *servers.GameServer, cancelMatch context.CancelFunc, matchResult chan DuelResult, )
func (*Duel) PollDeaths ¶
type DuelDone ¶
type DuelDone struct { Duel *Duel Result DuelResult }
type DuelResult ¶
type ELOState ¶
func NewELOState ¶
type Matchmaker ¶
type Matchmaker struct {
// contains filtered or unexported fields
}
func NewMatchmaker ¶
func NewMatchmaker(manager *servers.ServerManager, duelTypes []config.DuelType) *Matchmaker
func (*Matchmaker) Dequeue ¶
func (m *Matchmaker) Dequeue(user *User)
func (*Matchmaker) FindDuelType ¶
func (m *Matchmaker) FindDuelType(name string) opt.Option[config.DuelType]
func (*Matchmaker) NotifyProgress ¶
func (m *Matchmaker) NotifyProgress(queued *QueuedClient)
Inform the client regularly as to how long they've been in the queue.
func (*Matchmaker) Poll ¶
func (m *Matchmaker) Poll(ctx context.Context)
func (*Matchmaker) ReceiveQueues ¶
func (m *Matchmaker) ReceiveQueues() <-chan DuelQueue
func (*Matchmaker) ReceiveResults ¶
func (m *Matchmaker) ReceiveResults() <-chan DuelResult
type QueuedClient ¶
type RecordedPacket ¶
type TrackedPacket ¶
type User ¶
type User struct { *utils.Session Id ingress.ClientID // Whether the user is connected (or connecting) to a game server Status UserStatus Name string Connection ingress.Connection // Created when the user connects to a server and canceled when they // leave, regardless of reason (network or being disconnected by the // server) // This is NOT the same thing as Client.Connection.SessionContext(), which refers to // the lifecycle of the client's ingress connection ServerSession utils.Session Server *servers.GameServer ServerClient *gameserver.Client ELO *ELOState Space *verse.SpaceInstance From *P.MessageProxy To *P.MessageProxy RawFrom *utils.Topic[io.RawPacket] RawTo *utils.Topic[io.RawPacket] Mutex deadlock.RWMutex // contains filtered or unexported fields }
func (*User) AnnounceELO ¶
func (u *User) AnnounceELO()
func (*User) ConnectToServer ¶
func (*User) ConnectToSpace ¶
func (*User) DelayMessages ¶
func (c *User) DelayMessages()
func (*User) DisconnectFromServer ¶
Mark the client's status as disconnected and cancel its session context. Called both when the client disconnects from ingress AND when the server kicks them out.
func (*User) GetAutoexecKey ¶
func (*User) GetClientNum ¶
func (*User) GetFormattedName ¶
func (*User) GetFormattedReference ¶
func (*User) GetServer ¶
func (u *User) GetServer() *servers.GameServer
func (*User) GetServerInfo ¶
func (u *User) GetServerInfo() P.ServerInfo
func (*User) GetServerName ¶
func (*User) GetSessionID ¶
func (*User) GetSpace ¶
func (u *User) GetSpace() *verse.SpaceInstance
func (*User) GetStatus ¶
func (c *User) GetStatus() UserStatus
func (*User) HasCubeScript ¶
func (*User) RawMessage ¶
func (*User) ReceiveConnections ¶
func (c *User) ReceiveConnections() <-chan ConnectionEvent
func (*User) ReceiveToMessages ¶
func (c *User) ReceiveToMessages() <-chan TrackedPacket
func (*User) ResponseTimeout ¶
func (u *User) ResponseTimeout(ctx context.Context, timeout time.Duration, code P.MessageCode, messages ...P.Message) (P.Message, error)
ResponseTimeout sends a message for a user and waits for a response of type `code`.
func (*User) RestoreMessages ¶
func (c *User) RestoreMessages()
func (*User) SendChannel ¶
func (*User) SendChannelSync ¶
func (*User) ServerSessionContext ¶
type UserOrchestrator ¶
type UserOrchestrator struct { Duels []config.DuelType Users []*User Servers map[*servers.GameServer][]*User Mutex deadlock.RWMutex }
func NewUserOrchestrator ¶
func NewUserOrchestrator(duels []config.DuelType) *UserOrchestrator
func (*UserOrchestrator) AddUser ¶
func (u *UserOrchestrator) AddUser(ctx context.Context, connection ingress.Connection) (*User, error)
func (*UserOrchestrator) PollUser ¶
func (u *UserOrchestrator) PollUser(ctx context.Context, user *User)
func (*UserOrchestrator) RemoveUser ¶
func (u *UserOrchestrator) RemoveUser(user *User)
Click to show internal directories.
Click to hide internal directories.