Moving SF outcomingRPC to another thread

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
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?
 

0x_

Wtf I'm not new....
Administrator
Joined
Feb 18, 2013
Messages
1,116
Reaction score
167
Unfortunately multi threading isn't that easy.
The only real and true way would be you blocking the RPC and adding the chat message to some kind of queue which will get processed in another thread and then resend the RPC_CHAT packet.
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
0x688 said:
Unfortunately multi threading isn't that easy.
The only real and true way would be you blocking the RPC and adding the chat message to some kind of queue which will get processed in another thread and then resend the RPC_CHAT packet.

So by that queue system you mean I should block the RPC, completely block every CHAT RPC, then create a thread which would translate and wait and after translation is done, Send a completely new RPC right?
I see.. That should work. Thanks for the info
 

0x_

Wtf I'm not new....
Administrator
Joined
Feb 18, 2013
Messages
1,116
Reaction score
167
Top