agones: agones.dev/agones/sdks/go Index | Files

package sdk

import "agones.dev/agones/sdks/go"

Package sdk is the Go game server sdk

Index

Package Files

alpha.go sdk.go

type Alpha Uses

type Alpha struct {
    // contains filtered or unexported fields
}

Alpha is the struct for Alpha SDK functionality

func (*Alpha) GetConnectedPlayers Uses

func (a *Alpha) GetConnectedPlayers() ([]string, error)

GetConnectedPlayers returns the list of the currently connected player ids. This is always accurate, even if the value hasn’t been updated to the GameServer status yet.

func (*Alpha) GetPlayerCapacity Uses

func (a *Alpha) GetPlayerCapacity() (int64, error)

GetPlayerCapacity gets the last player capacity that was set through the SDK. If the player capacity is set from outside the SDK, use SDK.GameServer() instead.

func (*Alpha) GetPlayerCount Uses

func (a *Alpha) GetPlayerCount() (int64, error)

GetPlayerCount returns the current player count

func (*Alpha) IsPlayerConnected Uses

func (a *Alpha) IsPlayerConnected(id string) (bool, error)

IsPlayerConnected returns if the playerID is currently connected to the GameServer. This is always accurate, even if the value hasn’t been updated to the GameServer status yet.

func (*Alpha) PlayerConnect Uses

func (a *Alpha) PlayerConnect(id string) (bool, error)

PlayerConnect increases the SDK’s stored player count by one, and appends this playerID to status.players.id. Returns true and adds the playerID to the list of playerIDs if the playerIDs was not already in the list of connected playerIDs.

func (*Alpha) PlayerDisconnect Uses

func (a *Alpha) PlayerDisconnect(id string) (bool, error)

PlayerDisconnect Decreases the SDK’s stored player count by one, and removes the playerID from status.players.id Will return true and remove the supplied playerID from the list of connected playerIDs if the playerID value exists within the list.

func (*Alpha) SetPlayerCapacity Uses

func (a *Alpha) SetPlayerCapacity(capacity int64) error

SetPlayerCapacity changes the player capacity to a new value

type GameServerCallback Uses

type GameServerCallback func(gs *sdk.GameServer)

GameServerCallback is a function definition to be called when a GameServer CRD has been changed

type SDK Uses

type SDK struct {
    // contains filtered or unexported fields
}

SDK is an instance of the Agones SDK

func NewSDK Uses

func NewSDK() (*SDK, error)

NewSDK starts a new SDK instance, and connects to localhost on port 9357. Blocks until connection and handshake are made. Times out after 30 seconds.

func (*SDK) Allocate Uses

func (s *SDK) Allocate() error

Allocate self marks this gameserver as Allocated.

func (*SDK) Alpha Uses

func (s *SDK) Alpha() *Alpha

Alpha returns the Alpha SDK

func (*SDK) GameServer Uses

func (s *SDK) GameServer() (*sdk.GameServer, error)

GameServer retrieve the GameServer details

func (*SDK) Health Uses

func (s *SDK) Health() error

Health sends a ping to the health check to indicate that this server is healthy

func (*SDK) Ready Uses

func (s *SDK) Ready() error

Ready marks the Game Server as ready to receive connections

func (*SDK) Reserve Uses

func (s *SDK) Reserve(d time.Duration) error

Reserve marks the Game Server as Reserved for a given duration, at which point it will return the GameServer to a Ready state. Do note, the smallest unit available in the time.Duration argument is a second.

func (*SDK) SetAnnotation Uses

func (s *SDK) SetAnnotation(key, value string) error

SetAnnotation sets a metadata annotation on the `GameServer` with the prefix stable.agones.dev/sdk-

func (*SDK) SetLabel Uses

func (s *SDK) SetLabel(key, value string) error

SetLabel sets a metadata label on the `GameServer` with the prefix stable.agones.dev/sdk-

func (*SDK) Shutdown Uses

func (s *SDK) Shutdown() error

Shutdown marks the Game Server as ready to shutdown

func (*SDK) WatchGameServer Uses

func (s *SDK) WatchGameServer(f GameServerCallback) error

WatchGameServer asynchronously calls the given GameServerCallback with the current GameServer configuration when the backing GameServer configuration is updated. This function can be called multiple times to add more than one GameServerCallback.

Package sdk imports 10 packages (graph) and is imported by 12 packages. Updated 2020-05-15. Refresh now. Tools for package owners.