build
This commit is contained in:
@@ -28,6 +28,8 @@ class ClientModule : public Archimedes::Module {
|
||||
|
||||
}
|
||||
|
||||
bool isRunning() const { return running; }
|
||||
|
||||
void pollIncomingData();
|
||||
|
||||
void shouldHandleEvents(unsigned int events) { eventsToHandle = events; }
|
||||
|
||||
@@ -48,7 +48,7 @@ void ServerModule::startServer(int p) {
|
||||
pollGroup = interface->CreatePollGroup();
|
||||
if ( pollGroup == k_HSteamNetPollGroup_Invalid )
|
||||
std::cerr << "Failed to listen on port " << port << std::endl;
|
||||
//Printf( "Server listening on port %d\n", port );
|
||||
std::cerr << "Server listening on port " << port << std::endl;
|
||||
|
||||
running = true;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ class ServerModule : public Archimedes::Module {
|
||||
DataSent = 1 << 2
|
||||
};
|
||||
|
||||
bool isRunning() const { return running; }
|
||||
|
||||
void shouldHandleEvents(unsigned int events) { eventsToHandle = events; }
|
||||
|
||||
void sendReliable(HSteamNetConnection client, const void* data, uint32 byteCount) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user