common

package
v0.0.0-...-85804c7 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion uint = 3

APIVersion is the version of the REST API implemented in this file

View Source
const DefaultVic2GamePort uint16 = 1930
View Source
const SoftwareName = "vic2-multi-proxy"

SoftwareName is the name of this software

View Source
const SoftwareVersion = "v1.0.1-alpha"

SoftwareVersion is the version of this software

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthTokenCustomClaims

type AuthTokenCustomClaims struct {
	UserID uint64 `json:"uid"`
	jwt.StandardClaims
}

JWT Claims type for the authentication token

type CheckinResponse

type CheckinResponse struct {
	Lobbies     map[string]RestLobby `json:"lobbies"`
	Hosting     bool                 `json:"hosting"`
	LinkedLobby uint64               `json:"linkedTo"`
}

CheckinResponse is the JSON response to the /checkin REST method

type GameDataContainer

type GameDataContainer struct {
	// An identifier for the origin of this data packet, so the relay on the server or client can know where this came from
	Identifier uint64
	Data       []byte
}

func DecodeGameDataContainer

func DecodeGameDataContainer(data []byte) GameDataContainer

func (*GameDataContainer) Encode

func (container *GameDataContainer) Encode() []byte

type InfoResponse

type InfoResponse struct {
	Software string `json:"software"`
	Version  string `json:"version"`
	API      uint   `json:"apiVersion"`
}

InfoResponse is the JSON response to the /info REST method

type MessageConnection

type MessageConnection interface {
	// Reads a message, blocking
	ReadMessage() ([]byte, net.Addr, error)
	// Sends a message
	WriteMessage(data []byte) error
	// Sends a closing message and closes the connection. Some implementations (UDP) don't support sending a message, but will still close the connection
	CloseWithMessage(msg string) error
	// Closes the underlying socket
	Close() error
	// Determine if the connection has been closed or not
	IsClosed() bool
}

Represents a connection capable of sending full messages between each other This is an abstracted type of UDP/Websocket connections used by the relay code, primarily to allow mocks for testing purposes

type MessageConnectionProvider

type MessageConnectionProvider interface {
	// Creates and returns a new MessageConnection to listen on a certain port on the local machine
	ObtainLocalListener(port uint) (MessageConnection, error)
	// Creates and returns a new MessageConnection that is connected to the specified address
	DialForConnection(address string) (MessageConnection, error)
}

Represents a source for creating MessageConnections, for listening locally and also connecting to remote addresses

type RelayMessageConnectionProvider

type RelayMessageConnectionProvider struct {
}

Implements MessageConnectionProvider by creating UDP sockets for ObtainLocalListener, and websocket connections for DialForConnection

func (*RelayMessageConnectionProvider) DialForConnection

func (provider *RelayMessageConnectionProvider) DialForConnection(address string) (MessageConnection, error)

func (*RelayMessageConnectionProvider) ObtainLocalListener

func (provider *RelayMessageConnectionProvider) ObtainLocalListener(port uint) (MessageConnection, error)

type RestLobby

type RestLobby struct {
	Name string `json:"name"`
	Host string `json:"host"`
}

RestLobby represents a Lobby in the lobbies dictionary in the CheckinResponse struct

type UDPMessageConnection

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

UDP implementation of MessageConnection

func (*UDPMessageConnection) Close

func (connection *UDPMessageConnection) Close() error

func (*UDPMessageConnection) CloseWithMessage

func (connection *UDPMessageConnection) CloseWithMessage(msg string) error

func (*UDPMessageConnection) IsClosed

func (connection *UDPMessageConnection) IsClosed() bool

func (*UDPMessageConnection) ReadMessage

func (connection *UDPMessageConnection) ReadMessage() ([]byte, net.Addr, error)

func (*UDPMessageConnection) WriteMessage

func (connection *UDPMessageConnection) WriteMessage(data []byte) error

type WebsocketMessageConnection

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

func (*WebsocketMessageConnection) Close

func (connection *WebsocketMessageConnection) Close() error

func (*WebsocketMessageConnection) CloseWithMessage

func (connection *WebsocketMessageConnection) CloseWithMessage(msg string) error

func (*WebsocketMessageConnection) IsClosed

func (connection *WebsocketMessageConnection) IsClosed() bool

func (*WebsocketMessageConnection) ReadMessage

func (connection *WebsocketMessageConnection) ReadMessage() ([]byte, net.Addr, error)

func (*WebsocketMessageConnection) WriteMessage

func (connection *WebsocketMessageConnection) WriteMessage(data []byte) error

Jump to

Keyboard shortcuts

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