gateway

package
v0.0.0-...-641a42a Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetQuiet

func SetQuiet()

SetQuiet logging

Types

type Credentials

type Credentials struct {
	Username string
}

Credentials for authentication

type CurrentMatch

type CurrentMatch struct {
	BlackName                   string
	WhiteName                   string
	MaxTimeMs                   int64
	BlackRemainingTimeMs        int64
	WhiteRemainingTimeMs        int64
	Board                       model.SerializableBoard
	Turn                        model.Color
	GameOver                    bool
	Result                      model.GameResult
	PreviousMove                model.Move
	PreviousMover               model.Piece
	BlackKing                   model.Piece
	WhiteKing                   model.Piece
	WhitePieces                 map[model.PieceType]uint8
	BlackPieces                 map[model.PieceType]uint8
	PositionHistory             map[string]uint8
	TurnsSinceCaptureOrPawnMove uint8
	RequestedDraw               bool
	RequestedDrawName           string
}

CurrentMatch serializable struct to bring client up to speed

type Gateway

type Gateway struct {
	HTTPBackend *url.URL
	WSBackend   *url.URL
	BasePath    string
	Port        int
}

Gateway is the server that serves static files and proxies to the different backends

func (*Gateway) Serve

func (gw *Gateway) Serve()

Serve static files and proxy to the different backends

type SessionResponse

type SessionResponse struct {
	Credentials Credentials
	InMatch     bool
	Match       CurrentMatch
}

SessionResponse serializable struct to send client's session

type TTLMap

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

TTLMap is a map with a TTL

func NewTTLMap

func NewTTLMap(ln int, maxTTL int, gcFrequencySecs int) (m *TTLMap)

NewTTLMap creates a new map

func (*TTLMap) Get

func (m *TTLMap) Get(k string) (v *matchserver.Player, err error)

Get gets value for key k

func (*TTLMap) Len

func (m *TTLMap) Len() int

Len returns the length of the map

func (*TTLMap) Put

func (m *TTLMap) Put(k string, v *matchserver.Player) error

Put puts key k and value v

func (*TTLMap) Refresh

func (m *TTLMap) Refresh(k, newk string) error

Refresh updates the key k to newk

Jump to

Keyboard shortcuts

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