mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2025-08-18 12:15:36 +00:00
SocketIO work
This commit is contained in:
parent
57fc0ea74d
commit
aadcd1abe5
@ -11,15 +11,14 @@ SocketIO& SocketIO::Get() {
|
||||
SocketIO::SocketIO() noexcept
|
||||
: mThread([this] { ThreadMain(); }) {
|
||||
|
||||
mClient.socket("/" + Application::TSettings().Key)->on("Hello", [&](sio::event&) {
|
||||
info("Got 'Hello' from backend socket-io!");
|
||||
mClient.socket()->on("welcome", [&](sio::event&) {
|
||||
info("Got welcome from backend! Authenticating SocketIO...");
|
||||
mClient.socket()->emit("onInitConnection", Application::Settings.Key);
|
||||
});
|
||||
|
||||
mClient.set_logs_quiet();
|
||||
mClient.set_reconnect_delay(10000);
|
||||
mClient.connect("https://backend.beammp.com");
|
||||
|
||||
//mClient.socket()->emit("initConnection", Application::TSettings().Key);
|
||||
}
|
||||
|
||||
SocketIO::~SocketIO() {
|
||||
@ -77,18 +76,14 @@ void SocketIO::Emit(SocketIORoom Room, SocketIOEvent Event, const std::string& D
|
||||
}
|
||||
|
||||
void SocketIO::ThreadMain() {
|
||||
bool FirstTime = true;
|
||||
while (!mCloseThread.load()) {
|
||||
if (mAuthenticated && FirstTime) {
|
||||
FirstTime = false;
|
||||
}
|
||||
bool empty = false;
|
||||
bool empty;
|
||||
{ // queue lock scope
|
||||
std::unique_lock Lock(mQueueMutex);
|
||||
empty = mQueue.empty();
|
||||
} // end queue lock scope
|
||||
if (empty) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
if (empty || !mClient.opened()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
continue;
|
||||
} else {
|
||||
Event TheEvent;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/stringbuffer.h"
|
||||
#include "rapidjson/writer.h"
|
||||
|
||||
namespace json = rapidjson;
|
||||
|
||||
TServer::TServer(int argc, char** argv) {
|
||||
@ -234,6 +235,7 @@ void TServer::ParseVehicle(TClient& c, const std::string& Pckt, TTCPServer& TCPS
|
||||
PID = stoi(pid);
|
||||
VID = stoi(vid);
|
||||
}
|
||||
|
||||
if (PID != -1 && VID != -1 && PID == c.GetID()) {
|
||||
Data = Data.substr(Data.find('{'));
|
||||
TriggerLuaEvent("onVehicleReset", false, nullptr,
|
||||
|
Loading…
x
Reference in New Issue
Block a user