segfault
This commit is contained in:
@@ -58,7 +58,7 @@ class ClientModule : public Archimedes::Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnSteamNetConnectionStatusChanged( SteamNetConnectionStatusChangedCallback_t *pInfo ) {
|
void OnSteamNetConnectionStatusChanged( SteamNetConnectionStatusChangedCallback_t *pInfo ) {
|
||||||
app->emitEvent(new CMEvent::ConnectionStatusChangedEvent(pInfo));
|
app->emitEvent(new Archimedes::ConnectionStatusChangedEvent(pInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PollConnectionStateChanges() {
|
void PollConnectionStateChanges() {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ImguiModule : public Archimedes::Module {
|
|||||||
void releaseContext(ImGuiContext* ctxt) {
|
void releaseContext(ImGuiContext* ctxt) {
|
||||||
if(ctxt == context && context != nullptr) {
|
if(ctxt == context && context != nullptr) {
|
||||||
if(--contextRefs == 0) {
|
if(--contextRefs == 0) {
|
||||||
app->stopModule(name);
|
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ ServerModule::ServerModule(Archimedes::App* a, void* h) : Archimedes::Module(a,
|
|||||||
|
|
||||||
ServerModule::~ServerModule() {
|
ServerModule::~ServerModule() {
|
||||||
if(app) {
|
if(app) {
|
||||||
app->unregisterEvent(SMEvent::DataRecievedEvent());
|
app->unregisterEvent(Archimedes::DataRecievedEvent());
|
||||||
app->unregisterEvent(SMEvent::DataSentEvent());
|
app->unregisterEvent(Archimedes::DataSentEvent());
|
||||||
app->unregisterEvent(SMEvent::ConnectionStatusChangedEvent());
|
app->unregisterEvent(Archimedes::ConnectionStatusChangedEvent());
|
||||||
|
|
||||||
GameNetworkingSockets_Kill();
|
GameNetworkingSockets_Kill();
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,9 @@ ServerModule::~ServerModule() {
|
|||||||
|
|
||||||
void ServerModule::onLoad() {
|
void ServerModule::onLoad() {
|
||||||
|
|
||||||
app->registerEvent(SMEvent::DataRecievedEvent());
|
app->registerEvent(Archimedes::DataRecievedEvent());
|
||||||
app->registerEvent(SMEvent::DataSentEvent());
|
app->registerEvent(Archimedes::DataSentEvent());
|
||||||
app->registerEvent(SMEvent::ConnectionStatusChangedEvent());
|
app->registerEvent(Archimedes::ConnectionStatusChangedEvent());
|
||||||
|
|
||||||
SteamDatagramErrMsg errMsg;
|
SteamDatagramErrMsg errMsg;
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ bool ServerModule::onEvent(const Archimedes::Event& event) {
|
|||||||
|
|
||||||
unsigned int type = app->getEventType(event);
|
unsigned int type = app->getEventType(event);
|
||||||
|
|
||||||
if(eventsToHandle & SMEventEnum::ConnectionStatusChanged && type == app->getEventType(SMEvent::ConnectionStatusChangedEvent())) {
|
if(eventsToHandle & SMEventEnum::ConnectionStatusChanged && type == app->getEventType(Archimedes::ConnectionStatusChangedEvent())) {
|
||||||
|
|
||||||
SMEvent::ConnectionStatusChangedEvent& e = (SMEvent::ConnectionStatusChangedEvent&) event;
|
Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
|
||||||
|
|
||||||
switch(e.info->m_info.m_eState) {
|
switch(e.info->m_info.m_eState) {
|
||||||
|
|
||||||
@@ -194,9 +194,9 @@ bool ServerModule::onEvent(const Archimedes::Event& event) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if(eventsToHandle & SMEventEnum::DataRecieved && type == app->getEventType(SMEvent::DataRecievedEvent())) {
|
} else if(eventsToHandle & SMEventEnum::DataRecieved && type == app->getEventType(Archimedes::DataRecievedEvent())) {
|
||||||
return true;
|
return true;
|
||||||
} else if(eventsToHandle & SMEventEnum::DataSent && type == app->getEventType(SMEvent::DataSentEvent())) {
|
} else if(eventsToHandle & SMEventEnum::DataSent && type == app->getEventType(Archimedes::DataSentEvent())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +217,6 @@ void ServerModule::pollIncomingData() {
|
|||||||
auto itClient = clients.find( pIncomingMsg->m_conn );
|
auto itClient = clients.find( pIncomingMsg->m_conn );
|
||||||
assert( itClient != clients.end() );
|
assert( itClient != clients.end() );
|
||||||
|
|
||||||
app->emitEvent(new SMEvent::DataRecievedEvent(pIncomingMsg));
|
app->emitEvent(new Archimedes::DataRecievedEvent(pIncomingMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <steam/steamnetworkingsockets.h>
|
#include <steam/steamnetworkingsockets.h>
|
||||||
#include <steam/isteamnetworkingutils.h>
|
#include <steam/isteamnetworkingutils.h>
|
||||||
|
|
||||||
#include "ServerEvents.h"
|
#include "utils/Events/NetworkEvents.h"
|
||||||
|
|
||||||
class ServerModule : public Archimedes::Module {
|
class ServerModule : public Archimedes::Module {
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class ServerModule : public Archimedes::Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnSteamNetConnectionStatusChanged( SteamNetConnectionStatusChangedCallback_t *pInfo ) {
|
void OnSteamNetConnectionStatusChanged( SteamNetConnectionStatusChangedCallback_t *pInfo ) {
|
||||||
app->emitEvent(new SMEvent::ConnectionStatusChangedEvent(pInfo));
|
app->emitEvent(new Archimedes::ConnectionStatusChangedEvent(pInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<HSteamNetConnection, unsigned int> clients;
|
std::map<HSteamNetConnection, unsigned int> clients;
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ ChatClient::~ChatClient() {
|
|||||||
|
|
||||||
void ChatClient::onLoad() {
|
void ChatClient::onLoad() {
|
||||||
|
|
||||||
|
std::cerr << "onLoad\n";
|
||||||
|
|
||||||
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
||||||
|
|
||||||
if(!im) {
|
if(!im) {
|
||||||
std::cout << "No ImguiModule for TestImgui!\n";
|
std::cout << "No ClientModule for ChatClient!\n";
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +40,15 @@ void ChatClient::onLoad() {
|
|||||||
|
|
||||||
void ChatClient::run() {
|
void ChatClient::run() {
|
||||||
|
|
||||||
|
std::cerr << "run\n";
|
||||||
|
|
||||||
static ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; }
|
static ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; }
|
||||||
|
|
||||||
|
if(!cm) {
|
||||||
|
std::cout << "No ClientModule for ChatClient!\n";
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
if(open) {
|
if(open) {
|
||||||
static std::string s, addr = "127.0.0.1:9932";
|
static std::string s, addr = "127.0.0.1:9932";
|
||||||
|
|
||||||
@@ -81,6 +90,7 @@ void ChatClient::run() {
|
|||||||
|
|
||||||
bool ChatClient::onEvent(const Archimedes::Event& event) {
|
bool ChatClient::onEvent(const Archimedes::Event& event) {
|
||||||
|
|
||||||
|
std::cerr << "onEvent: " << (std::string) event << std::endl;
|
||||||
unsigned int type = app->getEventType(event);
|
unsigned int type = app->getEventType(event);
|
||||||
|
|
||||||
|
|
||||||
@@ -89,9 +99,9 @@ bool ChatClient::onEvent(const Archimedes::Event& event) {
|
|||||||
return true;
|
return true;
|
||||||
} else */
|
} else */
|
||||||
|
|
||||||
if(type == app->getEventType(CMEvent::DataRecievedEvent())) {
|
if(type == app->getEventType(Archimedes::DataRecievedEvent())) {
|
||||||
|
|
||||||
CMEvent::DataRecievedEvent& e = (CMEvent::DataRecievedEvent&) event;
|
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
|
||||||
|
|
||||||
static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize);
|
static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize);
|
||||||
|
|
||||||
@@ -103,7 +113,7 @@ bool ChatClient::onEvent(const Archimedes::Event& event) {
|
|||||||
}
|
}
|
||||||
/*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
|
/*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
|
||||||
|
|
||||||
//CMEvent::ConnectionStatusChangedEvent& e = (CMEvent::ConnectionStatusChangedEvent&) event;
|
//Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ bool ChatServer::onEvent(const Archimedes::Event& event) {
|
|||||||
return true;
|
return true;
|
||||||
} else */
|
} else */
|
||||||
|
|
||||||
if(type == app->getEventType(SMEvent::DataRecievedEvent())) {
|
if(type == app->getEventType(Archimedes::DataRecievedEvent())) {
|
||||||
|
|
||||||
static ServerModule* sm; { sm = (ServerModule*) moduleInstances[ServerModule()]; }
|
static ServerModule* sm; { sm = (ServerModule*) moduleInstances[ServerModule()]; }
|
||||||
|
|
||||||
SMEvent::DataRecievedEvent& e = (SMEvent::DataRecievedEvent&) event;
|
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
|
||||||
|
|
||||||
static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize);
|
static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize);
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ bool ChatServer::onEvent(const Archimedes::Event& event) {
|
|||||||
|
|
||||||
} /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
|
} /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
|
||||||
|
|
||||||
//SMEvent::ConnectionStatusChangedEvent& e = (SMEvent::ConnectionStatusChangedEvent&) event;
|
//Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MinimalApp : public Archimedes::App {
|
|||||||
void handleArgs(const int& argc, char* argv[]) override {
|
void handleArgs(const int& argc, char* argv[]) override {
|
||||||
if(argc > 1) {
|
if(argc > 1) {
|
||||||
for(int i = 1; i < argc; i++) {
|
for(int i = 1; i < argc; i++) {
|
||||||
load(dynamicLoad(argv[i]));
|
load(argv[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cout << "No modules to load\n";
|
std::cout << "No modules to load\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user