CUGL 2.5
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
cugl::net::NetcodeConfig Class Reference

#include <CUNetcodeConfig.h>

Public Member Functions

 NetcodeConfig ()
 
 NetcodeConfig (const InetAddress &lobby)
 
 NetcodeConfig (const InetAddress &lobby, const ICEAddress &iceServer)
 
 NetcodeConfig (const std::shared_ptr< JsonValue > &prefs)
 
 NetcodeConfig (const NetcodeConfig &src)=default
 
 NetcodeConfig (NetcodeConfig &&src)=default
 
 ~NetcodeConfig ()
 
NetcodeConfigoperator= (const NetcodeConfig &src)=default
 
NetcodeConfigoperator= (NetcodeConfig &&src)=default
 
NetcodeConfigset (const NetcodeConfig &src)
 
NetcodeConfigset (const std::shared_ptr< NetcodeConfig > &src)
 
NetcodeConfigset (const std::shared_ptr< JsonValue > &pref)
 

Public Attributes

bool secure
 
InetAddress lobby
 
std::vector< ICEAddressiceServers
 
bool multiplex
 
uint16_t portRangeBegin
 
uint16_t portRangeEnd
 
uint16_t mtu
 
size_t maxMessage
 
uint16_t maxPlayers
 
uint8_t apiVersion
 

Detailed Description

This class represents the configuration for our underlying Netcode.

Each NetcodeConnection has a configuration that cannot be changed once connection is established. This configuration controls such things as the initial lobby server (what the game connects to find other players), the ICE servers (used for NAT traversal), and communication settings like the MTU (maximum transmission unit). All all of these, only the lobby is required. Provided that the lobby is on the same network as the players, the default values for all of the other settings are sufficient.

The lobby MUST be the address of a websocket running the CUGL game lobby. While our netcode uses standard Web RTC signaling protocols, a generic signaling server will not give us the room management that we need.

When specifying ICE servers, the standard setup is to either specify a STUN and a TURN server, or a STUN server only. Specifying no ICE servers mean that only local connections are supported.

This class is effectively a simple struct. All attributes are publicly available and we do not use the standard CUGL shared pointer architecture. Internet addresses are designed to be use on the stack, though you can combine them with share pointers if you wish.

Constructor & Destructor Documentation

◆ NetcodeConfig() [1/6]

cugl::net::NetcodeConfig::NetcodeConfig ( )

Creates a new configuration.

All values will be defaults. The lobby server will be set to 'localhost" at port 8000 (e.g. the Django port).

◆ NetcodeConfig() [2/6]

cugl::net::NetcodeConfig::NetcodeConfig ( const InetAddress lobby)

Creates a new configuration with the given lobby server

All other values will be defaults. No ICE servers will be specified.

◆ NetcodeConfig() [3/6]

cugl::net::NetcodeConfig::NetcodeConfig ( const InetAddress lobby,
const ICEAddress iceServer 
)

Creates a new configuration with the given lobby and ICE server

All other values will be defaults. No ICE servers will be specified.

◆ NetcodeConfig() [4/6]

cugl::net::NetcodeConfig::NetcodeConfig ( const std::shared_ptr< JsonValue > &  prefs)

Creates this configuration using a JSON entry.

The JSON value should be an object with at least one key – "lobby" – which is the JSON for an InetAddress. All other keys are optional. They include:

 "secure":       A boolean indicating if the lobby uses SSL
 "ICE servers":  A list of {@link ICEAddress} JSONs
 "multiplex":    A boolean specifying whether to use UDP multiplexing
 "port range":   A list pair of the ports to scan
 "MTU":          An int representing the maximum transmission unit
 "max message":  An int respresenting the maximum transmission size
 "max players":  An int respresenting the maximum number of players
 "API version":  An int respresenting the API version
Parameters
prefsThe configuration settings

◆ NetcodeConfig() [5/6]

cugl::net::NetcodeConfig::NetcodeConfig ( const NetcodeConfig src)
default

Creates a copy of the configuration.

This copy constructor is provided so that internet addresses may be safely used on the stack, without the use of pointers.

Parameters
srcThe original configuration to copy

◆ NetcodeConfig() [6/6]

cugl::net::NetcodeConfig::NetcodeConfig ( NetcodeConfig &&  src)
default

Creates a new configuration with the resources of the given one.

This move constructor is provided so that internet addresses may be used efficiently on the stack, without the use of pointers.

Parameters
srcThe original configuration contributing resources

◆ ~NetcodeConfig()

cugl::net::NetcodeConfig::~NetcodeConfig ( )

Deletes this configuration, disposing all resources

Member Function Documentation

◆ operator=() [1/2]

NetcodeConfig & cugl::net::NetcodeConfig::operator= ( const NetcodeConfig src)
default

Assigns this configuration to be a copy of the given configuration.

Parameters
srcThe configuration to copy
Returns
a reference to this configuration for chaining purposes.

◆ operator=() [2/2]

NetcodeConfig & cugl::net::NetcodeConfig::operator= ( NetcodeConfig &&  src)
default

Assigns this configuration to have the resources of the given configuration.

Parameters
srcThe configuration to take resources from
Returns
a reference to this configuration for chaining purposes.

◆ set() [1/3]

NetcodeConfig & cugl::net::NetcodeConfig::set ( const NetcodeConfig src)

Assigns this configuration to be a copy of the given configuration.

Parameters
srcThe configuration to copy
Returns
a reference to this configuration for chaining purposes.

◆ set() [2/3]

NetcodeConfig & cugl::net::NetcodeConfig::set ( const std::shared_ptr< JsonValue > &  pref)

Assigns this configuration according to the given JSON object

which is the JSON for an InetAddress. All other keys are optional. They include:

 "secure":       A boolean indicating if the lobby uses SSL
 "ICE servers":  A list of {@link ICEAddress} JSONs
 "multiplex":    A boolean specifying whether to use UDP multiplexing
 "port range":   A list pair of the ports to scan
 "MTU":          An int representing the maximum transmission unit
 "max message":  An int respresenting the maximum transmission size
 "max players":  An int respresenting the maximum number of players
 "API version":  An int respresenting the API version
Parameters
prefThe address settings
Returns
a reference to this address for chaining purposes.

◆ set() [3/3]

NetcodeConfig & cugl::net::NetcodeConfig::set ( const std::shared_ptr< NetcodeConfig > &  src)

Assigns this configuration to be a copy of the given configuration.

Parameters
srcThe configuration to copy
Returns
a reference to this configuration for chaining purposes.

Member Data Documentation

◆ apiVersion

uint8_t cugl::net::NetcodeConfig::apiVersion

The API version number.

Clients with mismatched versions will be prevented from connecting to each other. Start this at 0 and increment it every time a backwards incompatible API change happens.

◆ iceServers

std::vector<ICEAddress> cugl::net::NetcodeConfig::iceServers

The collection of STUN/TURN servers to use (default None)

◆ lobby

InetAddress cugl::net::NetcodeConfig::lobby

The internet address for the lobby server

◆ maxMessage

size_t cugl::net::NetcodeConfig::maxMessage

The maximum message size (default 0 for automatic)

◆ maxPlayers

uint16_t cugl::net::NetcodeConfig::maxPlayers

The maximum number of players allowed (default 2)

◆ mtu

uint16_t cugl::net::NetcodeConfig::mtu

The maximum transmission unit (default 0 for automatic)

◆ multiplex

bool cugl::net::NetcodeConfig::multiplex

Whether to multiplex connections over a single UDP port (default false)

◆ portRangeBegin

uint16_t cugl::net::NetcodeConfig::portRangeBegin

The starting port to scan for connections (default 1024)

◆ portRangeEnd

uint16_t cugl::net::NetcodeConfig::portRangeEnd

The final port to scan for connections (default 65535)

◆ secure

bool cugl::net::NetcodeConfig::secure

Whether the lobby requires an SSL connection


The documentation for this class was generated from the following file: