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

#include <CUNetcodePeer.h>

Inheritance diagram for cugl::net::NetcodePeer:

Public Member Functions

 NetcodePeer ()
 
 ~NetcodePeer ()
 
std::string getUUID () const
 
const std::shared_ptr< NetcodeChannelgetChannel (const std::string channel)
 
const std::shared_ptr< NetcodeConnectiongetConnection ()
 
bool close ()
 
bool send (const std::string channel, const std::vector< std::byte > &data)
 
void setDebug (bool flag)
 
bool getDebug () const
 

Friends

class NetcodeChannel
 
class NetcodeConnection
 

Detailed Description

This class represents a peer connection.

While NetcodeConnection connects directly to the websocket server, peer connections are used to connect individual devices P2P (peer-to-peer). Each peer represents a connection between one device and another in the game. In turn, peers have one or more NetcodeChannel objects to communicate between them.

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

Constructor & Destructor Documentation

◆ NetcodePeer()

cugl::net::NetcodePeer::NetcodePeer ( )

Creates a degenerate RTC peer connection.

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

You should NEVER USE THIS CONSTRUCTOR. Peer connections should be created by a NetcodeConnection instead.

◆ ~NetcodePeer()

cugl::net::NetcodePeer::~NetcodePeer ( )

Deletes this RTC peer connection, disposing all resources

Member Function Documentation

◆ close()

bool cugl::net::NetcodePeer::close ( )

Closes this peer connection.

All associated data channels will be destroyed. In addition, this connection will be removed from this parent.

Returns
true if the channel was successfully closed.

◆ getChannel()

const std::shared_ptr< NetcodeChannel > cugl::net::NetcodePeer::getChannel ( const std::string  channel)

Returns the data channel with the associated label.

If there is no such channel, it returns nullptr. 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 data channel with the associated label.

◆ getConnection()

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

Returns the parent NetcodeConnection of 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 parent NetcodeConnection of this data channel

◆ getDebug()

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

Returns the debugging status of this peer.

If debugging is active, connections will be quite verbose

Returns
the debugging status of this channel.

◆ getUUID()

std::string cugl::net::NetcodePeer::getUUID ( ) const
inline

Returns the UUID of this peer

This value should correspond to NetcodeConnection#getUUID of the connected peer.

Returns
the UUID of this peer

◆ send()

bool cugl::net::NetcodePeer::send ( const std::string  channel,
const std::vector< std::byte > &  data 
)

Sends data along the data channel of the given name

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
channelThe data channel label
dataThe data to send (a string or byte vector)
Returns
true if transmission was (apparently) successful

◆ setDebug()

void cugl::net::NetcodePeer::setDebug ( bool  flag)

Toggles the debugging status of this peer.

If debugging is active, connections will be quite verbose

Parameters
flagWhether to activate debugging

Friends And Related Symbol Documentation

◆ NetcodeChannel

friend class NetcodeChannel
friend

Allow access to the other netcode classes


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