allow communication between clients
This commit is contained in:
@@ -39,6 +39,8 @@ class ServerModule : public Archimedes::Module {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<HSteamNetConnection, unsigned int> getClients() const { return clients; }
|
||||||
|
|
||||||
void pollIncomingData();
|
void pollIncomingData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -28,9 +28,12 @@ bool ChatServer::onEvent(const Archimedes::Event& event) {
|
|||||||
|
|
||||||
std::cerr << "Server Recieved: " << s << std::endl;
|
std::cerr << "Server Recieved: " << s << std::endl;
|
||||||
|
|
||||||
static std::string res; res = "Server Recieved: " + s;
|
for(auto& it : sm->getClients()) {
|
||||||
|
if(it.first != e.msg->m_conn)
|
||||||
sm->sendReliable(e.msg->m_conn, res.c_str(), res.length());
|
sm->sendReliable(it.first, s.c_str(), s.length());
|
||||||
|
else
|
||||||
|
sm->sendReliable(e.msg->m_conn, "\nMessage sent\n", strlen("\nMessage sent\n"));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user