Skip to content

Commit

Permalink
add a bunch of logs because i have no idea why its crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMario211 authored Aug 7, 2024
1 parent 212f2cb commit 33c9650
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ namespace ConnectionHandler {
}
}
bool setSocket(sio::socket::ptr sock) {
log::info("setSocket - called");
current_socket = sock;
log::info("setSocket - Set current_socket");
log::info("listening for events");
current_socket->emit(fmt::format("geode-{}", Mod::get()->getVersion()));
log::info("setSocket - emit event");
current_socket->on("rate", sio::socket::event_listener_aux([&](std::string const& user, sio::message::ptr const& data, bool isAck, sio::message::list &ack_resp) {
log::info("call rate event");
event_fired = true;
Expand All @@ -103,22 +106,31 @@ bool setSocket(sio::socket::ptr sock) {
}*/

void start_socket_func() {
log::info("Socket - start_socket_func");
while (true) {
log::info("Starting socket...");
sio::client sock;
sock.set_reconnect_delay(reconnectionDelay);
sock.set_reconnect_delay_max(reconnectionDelayMax);
sock.set_reconnect_attempts(reconnectionAttempts);
log::info("Socket - Set options");
sock.set_open_listener(&ConnectionHandler::onSuccess);
log::info("Socket - Set open listener");
sock.set_close_listener(&ConnectionHandler::onClose);
log::info("Socket - Set close listener");
sock.set_fail_listener(&ConnectionHandler::onFail);
log::info("Socket - Set fail listener");
sock.connect("http://gdutils.clarifygdps.com:13573");
log::info("Socket - Connect to socket server");
//sock.connect("http://gdutilstest.clarifygdps.com:46276");
if (!connect_finish) {
log::info("Socket - Wait for unique lock");
cond.wait(unique_lock);
}
sock.socket()->on_error(ConnectionHandler::onError);
log::info("Socket - Set on error event");
setSocket(sock.socket());
log::info("Socket - call setSocket");
while (still_connected) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
Expand Down Expand Up @@ -412,11 +424,16 @@ class $modify(MenuLayer) {
is_dailychest_ready = true;
}*/
if (!is_socketserver_started) {
log::info("Socket - MenuLayer::init");
bool startSocketServer = Mod::get()->getSettingValue<bool>("socketServer");
if (startSocketServer) {
log::info("Socket - Prepare Starting Socket Server");
current_socket = sio::socket::ptr();
log::info("Socket - Set current_socket");
std::thread hThread(start_socket_func);
log::info("Socket - Create new thread");
hThread.detach();
log::info("Socket - Detach thread");
}
is_socketserver_started = true;
}
Expand Down

0 comments on commit 33c9650

Please sign in to comment.