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

#include <CUNetcodeChannel.h>

Public Member Functions

 NetcodeChannel ()
 
 ~NetcodeChannel ()
 
const std::string getLabel () const
 
const std::shared_ptr< NetcodePeergetPeer ()
 
const std::shared_ptr< NetcodeConnectiongetConnection ()
 
bool close ()
 
bool send (const std::vector< std::byte > &data)
 
void setDebug (bool flag)
 
bool getDebug () const
 

Friends

class NetcodePeer
 
class NetcodeConnection
 

Detailed Description

This class represents a single data channel

Netcode communicates between devices on the network using data channels. A data channel is reliable, high speed communication that happens directly, and does not take place through the lobby server. A data channel is a relationship between two devices, providing bi-directional communication. It is possible for two devices to have more than one data channel between them, such as conversations marked private or public.

Users should not create data channels directly, and as such all constructors and allocators for this class are private. All data channels are associated with a NetcodePeer and should be constructed from them. We have only exposed this class to simplify development.

Constructor & Destructor Documentation

◆ NetcodeChannel()

cugl::net::NetcodeChannel::NetcodeChannel ( )

Creates a degenerate RTC data channel.

This object has not been initialized by a NetcodePeer and cannot be used.

You should NEVER USE THIS CONSTRUCTOR. All data channels should be created by a NetcodeConnection instead.

◆ ~NetcodeChannel()

cugl::net::NetcodeChannel::~NetcodeChannel ( )

Deletes this RTC data channel, disposing all resources

Member Function Documentation

◆ close()

bool cugl::net::NetcodeChannel::close ( )

Closes this data channel

The data channel will automatically be removed from its parent.

Returns
true if the channel was successfully closed.

◆ getConnection()

const std::shared_ptr< NetcodeConnection > cugl::net::NetcodeChannel::getConnection ( )

Returns the NetcodeConnection associated with this data channel

Most users should never need to access this method. It is provided for debugging purposes only.

This method is not const because it requires a lock.

Returns
the NetcodeConnection associated with this data channel

◆ getDebug()

bool cugl::net::NetcodeChannel::getDebug ( ) const
inline

Returns the debugging status of this channel.

If debugging is active, connections will be quite verbose

Returns
the debugging status of this channel.

◆ getLabel()

const std::string cugl::net::NetcodeChannel::getLabel ( ) const
inline

Returns the label for this data channel.

Each peer-to-peer pair has exactly one data channel with this label.

Returns
the label for this data channel.

◆ getPeer()

const std::shared_ptr< NetcodePeer > cugl::net::NetcodeChannel::getPeer ( )

Returns the parent NetcodePeer of this data channel

Most users should never need to access this method. All communication should take place using the associated NetcodeConnection. It is provided for debugging purposes only.

This method is not const because it requires a lock.

Returns
the parent NetcodePeer of this data channel

◆ send()

bool cugl::net::NetcodeChannel::send ( const std::vector< std::byte > &  data)

Sends data along this data channel to its recipient

Most users should never need to access this method. All communication should take place using the associated NetcodeConnection. It is provided for debugging purposes only.

Parameters
dataThe data to send
Returns
true if transmission was (apparently) successful

◆ setDebug()

void cugl::net::NetcodeChannel::setDebug ( bool  flag)
inline

Toggles the debugging status of this channel.

If debugging is active, connections will be quite verbose

Parameters
flagWhether to activate debugging

Friends And Related Symbol Documentation

◆ NetcodePeer

friend class NetcodePeer
friend

Allow access to the other netcode classes


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