CUGL 2.5
Cornell University Game Library
|
#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 NetworkLayer * | get () |
static bool | start (Log level=Log::NONE) |
static bool | stop () |
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
.
|
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 |
INFO | Log all important connection information This level will set |
DEVELOPER | Log all important developer information This level will set |
VERBOSE | Log all information available |
|
inlinestatic |
|
inline |
Returns true if the networking layer is in debug mode.
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.
level | The desired logging level |
|
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.