UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
Room Class Reference

#include <room.hpp>

Inheritance diagram for Room:
Inheritance graph
Collaboration diagram for Room:
Collaboration graph

Public Member Functions

 Room (std::string name)
 
void addClient (std::shared_ptr< Client > &&client)
 
bool isEmpty () const
 
bool isFull () const
 

Private Member Functions

void onClientCandidate (Client &client, CompletionStatus success)
 

Private Attributes

std::map< Client *, std::shared_ptr< Client > > clients
 
std::string name
 

Detailed Description

Definition at line 45 of file room.hpp.

Constructor & Destructor Documentation

◆ Room()

Room::Room ( std::string name)

Definition at line 41 of file room.cpp.

41: name(std::move(name)) { }
std::string name
Definition room.hpp:57

Member Function Documentation

◆ addClient()

void Room::addClient ( std::shared_ptr< Client > && client)

Definition at line 43 of file room.cpp.

43 {
44 assert(!isFull());
45
46 Client *clientPtr = client.get();
47
48 for(auto& [c, _] : clients){
49 c->sendMsg(clientPtr->getClientName());
50 c->sendMsg(clientPtr->getSdpDesc());
51
52 clientPtr->sendMsg(c->getClientName());
53 clientPtr->sendMsg(c->getSdpDesc());
54 for(const auto& candidate : c->getCandidates()){
55 clientPtr->sendMsg(candidate);
56 }
57 }
58
59 clients.insert({clientPtr, std::move(client)});
60
61 using namespace std::placeholders;
62 clientPtr->readCandidate(
63 std::bind(&Room::onClientCandidate, shared_from_this(), _1, _2));
64
65}
void sendMsg(std::string_view msg)
Definition client.cpp:123
void readCandidate(CompletionCallback onComplete)
Definition client.cpp:93
std::string getSdpDesc()
Definition client.hpp:63
std::string getClientName()
Definition client.hpp:61
bool isFull() const
Definition room.hpp:51
std::map< Client *, std::shared_ptr< Client > > clients
Definition room.hpp:58
void onClientCandidate(Client &client, CompletionStatus success)
Definition room.cpp:67

References clients, Client::getClientName(), Client::getSdpDesc(), isFull(), onClientCandidate(), Client::readCandidate(), and Client::sendMsg().

Here is the call graph for this function:

◆ isEmpty()

bool Room::isEmpty ( ) const
inline

Definition at line 52 of file room.hpp.

52{ return clients.empty(); }

References clients.

◆ isFull()

bool Room::isFull ( ) const
inline

Definition at line 51 of file room.hpp.

51{ return clients.size() >= 2; }

References clients.

Referenced by addClient().

◆ onClientCandidate()

void Room::onClientCandidate ( Client & client,
CompletionStatus success )
private

Definition at line 67 of file room.cpp.

67 {
70 std::cerr << "Unexpected disconnect";
72 std::cerr << "Client is disconnecting";
73 else
74 std::cerr << "Error reading candidate";
75
76 std::cerr << ", removing client " << client.getClientName() << std::endl;
77
78 clients.erase(&client);
79 return;
80 }
81
82 std::cout << "Client candidate recieved" << std::endl;
83
84 for(auto& [c, cu] : clients){
85 if(&client == c)
86 continue;
87
88 c->sendMsg(client.getCandidates().back());
89 }
90
91 using namespace std::placeholders;
92 client.readCandidate(
93 std::bind(&Room::onClientCandidate, shared_from_this(), _1, _2));
94}

References clients, GracefulDisconnect, onClientCandidate(), Success, and UnexpectedDisconnect.

Referenced by addClient(), and onClientCandidate().

Here is the call graph for this function:

Member Data Documentation

◆ clients

std::map<Client *, std::shared_ptr<Client> > Room::clients
private

Definition at line 58 of file room.hpp.

Referenced by addClient(), isEmpty(), isFull(), and onClientCandidate().

◆ name

std::string Room::name
private

Definition at line 57 of file room.hpp.


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