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

#include <CUNetworkLayer.h>

Public Types

enum class  Log : int {
  NONE = 0 , FATAL = 1 , ERRORS = 2 , WARNINGS = 3 ,
  NETCODE = 4 , INFO = 5 , DEVELOPER = 6 , VERBOSE = 7
}
 

Public Member Functions

bool isDebug () const
 

Static Public Member Functions

static NetworkLayerget ()
 
static bool start (Log level=Log::NONE)
 
static bool stop ()
 

Detailed Description

This class represents the networking subsystem.

We had originally hoped to do away with such a class. All devices have networking these days, right? However, CUGL does not use the built-in networking API. Instead it uses Web RTC to provide reliable high-speed communication between these devices. As an external subsystem, it must be initialized before use, and shutdown when finished. That is the primary purpose of this class.

As a singleton, this class has a private constructor. You should only access the singleton via the static method get. Furthermore, you create and deallocate the singleton with the start and stop methods appropriately.

While it is safe to construct internet addresses without this subsystem, you must initialize this system before using NetcodeConnection.

Member Enumeration Documentation

◆ Log

enum class cugl::net::NetworkLayer::Log : int
strong

This enum represents the desired logging for network debugging.

Setting a value of NETCODE or higher will cause the method isDebug to return true.

Enumerator
NONE 

Disable logging

FATAL 

Log only fatal errors

ERRORS 

Log all errors of any type

WARNINGS 

Log all errors and warnings

NETCODE 

Log all errors, warnings, and netcode specific messages

This setting (and anything higher), causes isDebug to return true. This level will cause netcode-specific debug messages to show but will not show anything other than warnings or errors for the underlying RTC layer.

INFO 

Log all important connection information

This level will set isDebug to true, showing all netcode-specific debug messages. In addition, it will show general info messages from the underlying RTC layer.

DEVELOPER 

Log all important developer information

This level will set isDebug to true, showing all netcode-specific debug messages. In addition, it will show detailed developer messages from the underlying RTC layer.

VERBOSE 

Log all information available

Member Function Documentation

◆ get()

static NetworkLayer * cugl::net::NetworkLayer::get ( )
inlinestatic

Returns a reference to the networking layer singleton.

If the method start has not yet been called (or if the system has been shutdown with the method stop), this method will return nullptr.

Returns
a reference to the networking layer singleton.

◆ isDebug()

bool cugl::net::NetworkLayer::isDebug ( ) const
inline

Returns true if the networking layer is in debug mode.

Returns
true if the networking layer is in debug mode.

◆ start()

static bool cugl::net::NetworkLayer::start ( Log  level = Log::NONE)
static

Starts up the RTC networking layer

Once this method is called, the get method will no longer return nullptr. The class NetcodeConnection require this method before it can properly be used.

Parameters
levelThe desired logging level
Returns
true if the network sublayer was successfully initialized

◆ stop()

static bool cugl::net::NetworkLayer::stop ( )
static

Shuts down the RTC networking layer

Once this method is called, the get method will always return nullptr. Any existing instances of NetcodeConnection will immediately be disconnected, and any further connection attempts will fail.

Returns
true if the network sublayer was successfully shut down

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