work on ClientModule, add ChatServer

This commit is contained in:
2025-04-17 14:16:57 -05:00
parent 2c903c276d
commit f36f6ae125
12 changed files with 314 additions and 53 deletions

View File

@@ -0,0 +1,40 @@
#include "ChatServer.h"
//void ChatServer::onLoad() {}
//void ChatServer::run() {}
bool ChatServer::onEvent(const Archimedes::Event& event) {
unsigned int type = app->getEventType(event);
/*if(type == app->getEventType("DataSentEvent")) {
//we did this?
return true;
} else */
if(type == app->getEventType("DataRecievedEvent")) {
static ServerModule* sm; { sm = (ServerModule*) moduleInstances[ServerModule()]; }
SMEvent::DataRecievedEvent& e = (SMEvent::DataRecievedEvent&) event;
static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize);
std::cerr << "Data Recieved: " << s << std::endl;
static std::string res; res = "Message Recieved: " + s;
sm->sendReliable(e.msg->m_conn, res.c_str(), res.length());
} /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
//SMEvent::ConnectionStatusChangedEvent& e = (SMEvent::ConnectionStatusChangedEvent&) event;
return false;
}*/
return false;
}