work on ClientModule, add ChatServer
This commit is contained in:
40
modules/examples/ChatServer/src/ChatServer.cpp
Normal file
40
modules/examples/ChatServer/src/ChatServer.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user