Closed redbaty closed 7 years ago
I never had subdomains in mind when developing this, which means it unfortunately isn't even close to following the HTTP spec for them. I originally created this include because I was experiencing issues with the SteamWorks extension. However, since then, those issues have been fixed or proven themselves minor enough for me to start using that extension again. For that reason, I'd recommend you consider using SteamWorks too - from what I know it officially supports the HTTP spec and has fairly similar syntax. Here's your code using SteamWorks:
#include <sourcemod>
#include <SteamWorks>
public void OnPluginStart()
{
RegAdminCmd("sm_api_register", Command_Register, ADMFLAG_SLAY);
}
public Action Command_Register(int client, int args)
{
PrintToServer("Requesting match ID from project nun");
Handle req = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, "http://projectnun.azurewebsites.net/api/heartbeat/register");
SteamWorks_SetHTTPCallbacks(req, OnRequestComplete);
SteamWorks_SetHTTPRequestHeaderValue(req, "User-Agent", "HTTPRequests for SourceMod");
SteamWorks_SendHTTPRequest(req);
}
public int OnRequestComplete(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode)
{
int length;
SteamWorks_GetHTTPResponseBodySize(hRequest, length);
char[] sBody = new char[length];
SteamWorks_GetHTTPResponseBodyData(hRequest, sBody, length);
PrintToServer("Received");
}
Hello, I'm somewhat new to pawn and I'm trying to contact my api using the following code:
however it'll never receive anything, the last thing on the output console is :
and it stays still. Am I missing something or is it really a bug ?
Anyway thanks for your attention and congratulations on your work so far