Quote:
Originally Posted by dubbeh
Came accross an issue, that I'm a bit stumped about because it's working perfectly for me.
https://github.com/dubbeh/motd-fixer...df/register.sp
Full Source:
Code:
public Action Command_MOTDRegisterServer(int iClient, int iArgs)
{
char szRegisterURL[192] = "";
Handle hHTTPRequest = INVALID_HANDLE;
if (g_cVarEnable.BoolValue)
{
if (g_cVarValidateType.IntValue == VALIDATE_TOKEN)
{
if (SteamWorks_IsLoaded())
{
Format(szRegisterURL, sizeof(szRegisterURL), "%s?server=1", g_szRegisterURL);
if ((hHTTPRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, szRegisterURL)) != INVALID_HANDLE)
{
if (SetServerInfoPostData(hHTTPRequest) &&
SteamWorks_SetHTTPCallbacks(hHTTPRequest, SteamWorks_OnRegisterComplete) &&
SteamWorks_SendHTTPRequest(hHTTPRequest))
{
MOTDFLogMessage("Registering server.");
} else {
MOTDFLogMessage("Error setting HTTP request data for server registration.");
}
}
} else {
SetFailState("SteamWorks doesn't appear to be loaded. Make sure to have it installed and running first.");
}
} else {
ReplyToCommand(iClient, "No need to register under IP based validation");
}
}
}
public void SteamWorks_OnRegisterComplete(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode)
{
char szResponseData[512] = "";
int iResponseSize = 0;
char szJSONResMsg[512];
bool bIsBlocked = false;
if (!bFailure && bRequestSuccessful && eStatusCode == k_EHTTPStatusCode200OK)
{
if (SteamWorks_GetHTTPResponseBodySize(hRequest, iResponseSize) && SteamWorks_GetHTTPResponseBodyData(hRequest, szResponseData, iResponseSize))
{
MOTDFLogMessage("SteamWorks_OnRegisterComplete() JSON Response: %s", szResponseData);
if (ReadJSONResponse(szResponseData, szJSONResMsg, sizeof(szJSONResMsg), bIsBlocked, g_szServerToken, sizeof(g_szServerToken)))
{
MOTDFLogMessage(szJSONResMsg);
if (g_szServerToken[0])
{
cfg.Save();
}
} else {
MOTDFLogMessage("SteamWorks_OnRegisterComplete() Error: %s - IsBlocked: %s", szJSONResMsg, bIsBlocked ? "TRUE" : "FALSE");
}
} else {
MOTDFLogMessage("SteamWorks_OnRegisterComplete() Error retrieving registration response data.");
}
} else {
MOTDFLogMessage("SteamWorks_OnRegisterComplete() Error: Response code %d .", eStatusCode);
}
CloseHandle(hRequest);
}
What's basically happening - They're getting to
Code:
MOTDFLogMessage("Registering server.");
but nothing after that point.
Was thinking if it was a CloudFlare issue possibly? but it's working fine for me without problems but that's testing on a residential IP.
Hopefully someone has possible ideas on the cause,
Thanks
Edit:
They're using NFO Servers as the host - if that helps.
|
Slew of issues...
You're not returning Plugin_Handled in your command callback.
Is this timing out? Try setting SteamWorks_SetHTTPRequestNetworkActivityTimeo ut.
You're raw printing strings and double formatting strings, MOTDFLogMessage(szJSONResMsg); is a disaster.
Your SteamWorks_IsLoaded() call is wrong and you should be using GetFeatureStatus.
Have you checked your SM error logs?