coordinator

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConnectionRequest added in v2.6.0

func GetConnectionRequest(data string) (api.ConnectionRequest, error)

func New

func New(conf coordinator.Config) (services service.Group)

func NewHTTPServer added in v2.6.0

func NewHTTPServer(conf coordinator.Config, fnMux func(mux *http.ServeMux)) (*httpx.Server, error)

Types

type BrowserClient

type BrowserClient struct {
	*cws.Client
	SessionID string
	RoomID    string
	WorkerID  string // TODO: how about pointer to workerClient?
}

func NewBrowserClient

func NewBrowserClient(c *websocket.Conn, browserID string) *BrowserClient

NewCoordinatorClient returns a client connecting to browser. This connection exchanges information between browser and coordinator.

func (*BrowserClient) Printf

func (bc *BrowserClient) Printf(format string, args ...interface{})

Register new log

func (*BrowserClient) Println

func (bc *BrowserClient) Println(args ...interface{})

type Server

type Server struct {
	service.Service
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg coordinator.Config, library games.GameLibrary) *Server

func (*Server) WS

func (s *Server) WS(w http.ResponseWriter, r *http.Request)

WSO handles all connections from user/frontend to coordinator

func (*Server) WSO

func (s *Server) WSO(w http.ResponseWriter, r *http.Request)

WSO handles all connections from a new worker to coordinator

type WorkerClient

type WorkerClient struct {
	*cws.Client

	WorkerID string
	Address  string // ip address of worker
	// public server used for ping check
	PingServer     string
	StunTurnServer string

	Zone string
	// contains filtered or unexported fields
}

func NewWorkerClient

func NewWorkerClient(c *websocket.Conn, workerID string) *WorkerClient

NewWorkerClient returns a client connecting to worker. This connection exchanges information between workers and server.

func (*WorkerClient) ChangeUserQuantityBy added in v2.6.0

func (wc *WorkerClient) ChangeUserQuantityBy(n int)

ChangeUserQuantityBy increases or decreases the total amount of users connected to the current worker. We count users to determine when the worker becomes new game ready.

func (*WorkerClient) HasGameSlot added in v2.6.0

func (wc *WorkerClient) HasGameSlot() bool

HasGameSlot tells whether the current worker has a free slot to start a new game. Workers support only one game at a time.

func (*WorkerClient) Printf

func (wc *WorkerClient) Printf(format string, args ...interface{})

func (*WorkerClient) Println

func (wc *WorkerClient) Println(args ...interface{})

Jump to

Keyboard shortcuts

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