#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(SMEvent::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; }