Help us shape the future of Go! Take the 2026 Go Developer Survey

gameliftgo

package module
v0.0.0-...-63cb264 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 4 Imported by: 0

README

gameliftgo

golang (1.10+) wrapper for GameLift Server SDK (2/15/18)

import (
	"log"

	"github.com/marchinram/gameliftgo"
)

func onStartGameSession(gameSession gameliftgo.GameSession) {
  if err := gameliftgo.ActivateGameSession(); err != nil {
    log.Println(err)
  }
}

func onProcessTerminate() {
}

func onHealthCheck() bool {
  return true
}

func main() {  
  if err := gameliftgo.InitSDK(); err != nil {
    log.Fatal(err)
  }
  
  port := 8080
  logPaths := []string{"./logs"}
  if err := gameliftgo.ProcessReady(onStartGameSession, onProcessTerminate, onHealthCheck, port, logPaths); err != nil {
    log.Fatal(err)
  }
  
//  ... Run server loop ...
  
  gameliftgo.ProcessEnding()
  gameliftgo.Destroy()
}

Documentation

Index

Constants

View Source
const (
	ErrAlreadyInitialized           GameLiftErrorType = iota
	ErrFleetMismatch                                  = iota
	ErrGameliftClientNotInitialized                   = iota
	ErrGameliftServerNotInitialized                   = iota
	ErrGameSessionEndedFailed                         = iota
	ErrGameSessionNotReady                            = iota
	ErrGameSessionReadyFailed                         = iota
	ErrInitializationMismatch                         = iota
	ErrNotInitialized                                 = iota
	ErrNoTargetAliasIDSet                             = iota
	ErrNoTargetFleetSet                               = iota
	ErrProcessEndingFailed                            = iota
	ErrProcessNotActive                               = iota
	ErrProcessNotReady                                = iota
	ErrProcessReadyFailed                             = iota
	ErrSDKVersionDetectionFailed                      = iota
	ErrServiceCallFailed                              = iota
	ErrSTXCallFailed                                  = iota
	ErrSTXInitializationFailed                        = iota
	ErrUnexpectedPlayerSession                        = iota
)
View Source
const (
	GameSessionStatusNotSet      GameSessionStatus = "NOT_SET"
	GameSessionStatusActive                        = "ACTIVE"
	GameSessionStatusActivating                    = "ACTIVATING"
	GameSessionStatusTerminated                    = "TERMINATED"
	GameSessionStatusTerminating                   = "TERMINATING"
)
View Source
const (
	PlayerSessionStatusNotSet    PlayerSessionStatus = "NOT_SET"
	PlayerSessionStatusReserved                      = "RESERVED"
	PlayerSessionStatusActive                        = "ACTIVE"
	PlayerSessionStatusCompleted                     = "COMPLETED"
	PlayerSessionStatusTimedout                      = "TIMEDOUT"
)
View Source
const (
	PlayerSessionCreationPolicyNotSet    PlayerSessionCreationPolicy = 0
	PlayerSessionCreationPolicyAcceptAll                             = 1
	PlayerSessionCreationPolicyDenyAll                               = 2
)

Variables

This section is empty.

Functions

func AcceptPlayerSession

func AcceptPlayerSession(playerSessionID string) error

func ActivateGameSession

func ActivateGameSession() error

func Destroy

func Destroy() error

func InitSDK

func InitSDK() error

func ProcessEnding

func ProcessEnding() error

func ProcessReady

func ProcessReady(onStartGameSession func(GameSession), onProcessTerminate func(), onHealthCheck func() bool, port int, logPaths []string) error

func RemovePlayerSession

func RemovePlayerSession(playerSessionID string) error

func TerminateGameSession

func TerminateGameSession() error

func UpdatePlayerSessionCreationPolicy

func UpdatePlayerSessionCreationPolicy(newPlayerSessionPolicy PlayerSessionCreationPolicy) error

Types

type DescribePlayerSessionsRequest

type DescribePlayerSessionsRequest struct {
	GameSessionID             string
	Limit                     int
	NextToken                 string
	PlayerID                  string
	PlayerSessionID           string
	PlayerSessionStatusFilter string
}

type DescribePlayerSessionsResult

type DescribePlayerSessionsResult struct {
	NextToken      string
	PlayerSessions []PlayerSession
}

type GameLiftError

type GameLiftError struct {
	ErrorType GameLiftErrorType
}

func (*GameLiftError) Error

func (e *GameLiftError) Error() string

type GameLiftErrorType

type GameLiftErrorType int

type GameSession

type GameSession struct {
	GameSessionID             string
	Name                      string
	FleetID                   string
	MaximumPlayerSessionCount int
	Status                    GameSessionStatus
	GameProperties            map[string]string
	IPAddress                 string
	Port                      int
	GameSessionData           string
	MatchmakerData            string
	DNSName                   string
}

type GameSessionStatus

type GameSessionStatus string

type PlayerSession

type PlayerSession struct {
	PlayerSessionID string
	PlayerID        string
	GameSessionID   string
	FleetID         string
	CreationTime    time.Time
	TerminationTime time.Time
	Status          PlayerSessionStatus
	IPAddress       string
	Port            int
	PlayerData      string
	DNSName         string
}

type PlayerSessionCreationPolicy

type PlayerSessionCreationPolicy int

type PlayerSessionStatus

type PlayerSessionStatus string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL