This commit is contained in:
2025-04-17 17:28:47 -05:00
parent a1e9401aaa
commit a79f40c66c
8 changed files with 135 additions and 4 deletions

View File

@@ -23,7 +23,43 @@ void ChatClient::run() {
static ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; }
(void)cm;
if(open) {
static std::string s, addr;
ImGui::Begin("ChatClient Module", &open);
ImGui::InputText("Server Address: ", &addr);
if(cm->isRunning()) {
if(ImGui::Button("Disconnect") && cm->isRunning()) {
cm->stopClient();
}
} else {
if(ImGui::Button("Connect") && !cm->isRunning()) {
static SteamNetworkingIPAddr serverAddr;
serverAddr.ParseString(addr.c_str());
cm->startClient(serverAddr);
}
}
ImGui::Text("%s", messages.c_str());
ImGui::InputText("Message: ", &s);
ImGui::SameLine();
if(ImGui::Button("send")) {
cm->sendReliable(s.c_str(), (uint32) s.length());
}
ImGui::End();
} else {
app->stopModule(name);
}
}
bool ChatClient::onEvent(const Archimedes::Event& event) {

View File

@@ -23,5 +23,11 @@ class ChatClient : public Archimedes::Module {
bool onEvent(const Archimedes::Event&);
private:
std::string messages;
std::string messages = "";
bool open = true;
};
#ifdef CHATCLIENT_DYNAMIC
#define MODULE_TYPE ChatClient
#include "endModule.h"
#endif

View File

@@ -27,3 +27,8 @@ class ChatServer : public Archimedes::Module {
bool onEvent(const Archimedes::Event&);
};
#ifdef CHATSERVER_DYNAMIC
#define MODULE_TYPE ChatServer
#include "endModule.h"
#endif