Giter VIP home page Giter VIP logo

Comments (1)

clugg avatar clugg commented on September 16, 2024 1

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");
}

from sm-httpreq.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.