Skip to content

Commit

Permalink
remove the logs and such
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMario211 committed Aug 10, 2024
1 parent b8dc5bd commit 8d99077
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
1 change: 0 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* <cg>Added</c> GDUtils GFX and GD Awards badges.
* <cg>Added</c> setting to show buttons for previewing icons colors when they are not unlocked.
* <cy>Changed</c> badges for GDUtils Developer and GDUtils collaborator badges.
* <cy>Fixed</c> crash with Notifications Server conflicting with Mega Hack.

## <cj>v1.3.7</c> <cb>(2024-07-28)</c>
* <cg>Added</c> Notifications SFX settings
Expand Down
50 changes: 37 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,8 @@ 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 @@ -104,23 +100,17 @@ 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;
connect_finish = false;
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");
auto start_time = std::chrono::steady_clock::now();
while (!connect_finish) {
if (std::chrono::steady_clock::now() - start_time > std::chrono::seconds(10)) {
Expand All @@ -131,9 +121,7 @@ void start_socket_func() {
}
if (connect_finish) {
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 @@ -427,6 +415,41 @@ class $modify(MenuLayer) {
hThread.detach();
is_dailychest_ready = true;
}*/
if (!is_socketserver_started) {
bool startSocketServer = Mod::get()->getSettingValue<bool>("socketServer");
if (startSocketServer) {
current_socket = sio::socket::ptr();
std::thread hThread(start_socket_func);
hThread.detach();
}
is_socketserver_started = true;
}
return true;
}
};

/*
class $modify(MyMenuLayerGDUTILS, MenuLayer) {
bool init() {
if (!MenuLayer::init()) return false;
// delete this
auto myButton = CCMenuItemSpriteExtra::create(
CCSprite::createWithSpriteFrameName("GJ_likeBtn_001.png"),
this,
menu_selector(MyMenuLayerGDUTILS::onMyButton)
);
// delete this
auto menu = this->getChildByID("bottom-menu");
menu->addChild(myButton);
myButton->setID("my-button"_spr);
menu->updateLayout();
return true;
}
void onMyButton(CCObject*) {
if (!is_socketserver_started) {
log::info("Socket - MenuLayer::init");
bool startSocketServer = Mod::get()->getSettingValue<bool>("socketServer");
Expand All @@ -441,9 +464,10 @@ class $modify(MenuLayer) {
}
is_socketserver_started = true;
}
return true;
}
};
*/

// When the socket connection is made
$on_mod(Loaded) {
Expand Down

0 comments on commit 8d99077

Please sign in to comment.