refactor
This commit is contained in:
58
modules/examples/ChatClient/src/ChatClient.cpp
Normal file
58
modules/examples/ChatClient/src/ChatClient.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "ChatClient.h"
|
||||
|
||||
|
||||
ChatClient::ChatClient(Archimedes::App* a, void* h) : Module(a, h) {
|
||||
|
||||
name = "ChatClient";
|
||||
|
||||
ClientModule* cm = new ClientModule(a, h);
|
||||
deps[*cm] = cm;
|
||||
cm->shouldHandleEvents(ClientModule::CMEventEnum::ConnectionStatusChanged | ClientModule::CMEventEnum::DataSent);
|
||||
|
||||
ImguiModule* im = new ImguiModule(a, h);
|
||||
|
||||
deps[*im] = im;
|
||||
}
|
||||
|
||||
void ChatClient::onLoad() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ChatClient::run() {
|
||||
|
||||
static ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; }
|
||||
|
||||
(void)cm;
|
||||
}
|
||||
|
||||
bool ChatClient::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(CMEvent::DataRecievedEvent())) {
|
||||
|
||||
CMEvent::DataRecievedEvent& e = (CMEvent::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;
|
||||
|
||||
messages += "\n\n" + s;
|
||||
}
|
||||
/*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
|
||||
|
||||
//CMEvent::ConnectionStatusChangedEvent& e = (CMEvent::ConnectionStatusChangedEvent&) event;
|
||||
|
||||
return false;
|
||||
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
27
modules/examples/ChatClient/src/ChatClient.h
Normal file
27
modules/examples/ChatClient/src/ChatClient.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
#include "modules/ClientModule/src/ClientModule.h"
|
||||
|
||||
#include "modules/ImguiModule/src/ImguiModule.h"
|
||||
|
||||
class ChatClient : public Archimedes::Module {
|
||||
|
||||
public:
|
||||
|
||||
ChatClient(Archimedes::App* a, void* h);
|
||||
|
||||
ChatClient() { name = "ChatClient"; }
|
||||
|
||||
~ChatClient() {
|
||||
if(app) {}
|
||||
}
|
||||
|
||||
void onLoad();
|
||||
|
||||
void run();
|
||||
|
||||
bool onEvent(const Archimedes::Event&);
|
||||
|
||||
private:
|
||||
std::string messages;
|
||||
};
|
||||
Reference in New Issue
Block a user