0x32789
Expert
I'm trying to get response from a website then put change the RPC_CHAT code but since everyone's net have different speed which means it isn't instant, I'm trying to make the outcomingRPC thread wait until the website completes response, but unfortunately it freezes the main thread..
What I have tried ->
Create outcoming RPC hook from different thread (Which is not connected to main thread) - Freezes main thread once I put while(translated == false) { Sleep(10); }
I've tried to add Sleep(1000); in outcomingRPC thread and it turns out even if it is created from another thread, It is still conneted to main SF thread..
Anyway I can put SF raknet in other thread or put the outcomingRPC in other thread/stop it from hanging?
This is my code currently used for the website work.
[shcode=cpp]
bool CALLBACK outcomingRPC(stRakNetHookParams * params)
{
Sleep(1000); // THIS WAS ONLY ADDED FOR TESTING the freezes
if (params->packetId == RPCEnumeration::RPC_Chat)
{
if (translatorEnabled)
{
DWORD strlen;
char string[127];
params->bitStream->ResetReadPointer();
params->bitStream->Read(strlen);
params->bitStream->Read(string, strlen);
string[strlen] = '\0';
std::thread tlThread(Translate, translatorLang, string, "trnsl.1.1.20170222T165522Z.0373f2f9d112f850.0670250561a8c0764e7b46cc71ea9ba3dbb989fe");
tlThread.detach();
while (translated == false)
{
Sleep(10);
}
if (translated == true)
{
translated = false;
params->bitStream->ResetWritePointer();
params->bitStream->Write(lenX);
params->bitStream->Write(ResultBuffer);
}
return true;
}
}
return true;
}
[/shcode]
@0x688 master?
What I have tried ->
Create outcoming RPC hook from different thread (Which is not connected to main thread) - Freezes main thread once I put while(translated == false) { Sleep(10); }
I've tried to add Sleep(1000); in outcomingRPC thread and it turns out even if it is created from another thread, It is still conneted to main SF thread..
Anyway I can put SF raknet in other thread or put the outcomingRPC in other thread/stop it from hanging?
This is my code currently used for the website work.
[shcode=cpp]
bool CALLBACK outcomingRPC(stRakNetHookParams * params)
{
Sleep(1000); // THIS WAS ONLY ADDED FOR TESTING the freezes
if (params->packetId == RPCEnumeration::RPC_Chat)
{
if (translatorEnabled)
{
DWORD strlen;
char string[127];
params->bitStream->ResetReadPointer();
params->bitStream->Read(strlen);
params->bitStream->Read(string, strlen);
string[strlen] = '\0';
std::thread tlThread(Translate, translatorLang, string, "trnsl.1.1.20170222T165522Z.0373f2f9d112f850.0670250561a8c0764e7b46cc71ea9ba3dbb989fe");
tlThread.detach();
while (translated == false)
{
Sleep(10);
}
if (translated == true)
{
translated = false;
params->bitStream->ResetWritePointer();
params->bitStream->Write(lenX);
params->bitStream->Write(ResultBuffer);
}
return true;
}
}
return true;
}
[/shcode]
@0x688 master?