server

package
v0.0.0-...-d64fcf2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	ID               string
	GameServers      map[string]*game.Server
	AMQPClient       *rabbitmq.Client
	RedisClient      *redis.Client
	OutgoingMessages chan *messaging.Container
	// contains filtered or unexported fields
}

Dispatcher creates new game servers for open games

func NewDispatcher

func NewDispatcher(
	id string,
	metricsCollector *instrumentation.MetricsCollector,
	redisURL string,
	redisPass string,
	amqpURL string,
	amqpUser string,
	amqpPass string,
	sessionsURL string,
) (*Dispatcher, error)

NewDispatcher creates a new dispatcher object

func (*Dispatcher) BootstrapDispatcher

func (d *Dispatcher) BootstrapDispatcher()

BootstrapDispatcher starts the asynchronus goroutines for managing messages

func (*Dispatcher) HandleIdleTimeoutCheck

func (d *Dispatcher) HandleIdleTimeoutCheck()

HandleIdleTimeoutCheck checks game servers for idle timeout and shuts them down if applicable

func (*Dispatcher) LoadFromState

func (d *Dispatcher) LoadFromState() error

LoadFromState starts all persisted game servers from redis

func (*Dispatcher) ServeHTTP

func (d *Dispatcher) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP satisfies the http handler interface

func (*Dispatcher) StartNewGameServer

func (d *Dispatcher) StartNewGameServer(
	title string,
	cardDeck *messaging.CardDeckType,
	overrideID string,
	loadedFromState bool,
) *game.Server

StartNewGameServer creates a new GameDispatcher and runs it in a new goroutine

Jump to

Keyboard shortcuts

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