Raised This Month: $51 Target: $400
 12% 

SteamWorks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 01-26-2016 , 13:03   SteamWorks
Reply With Quote #1

Hello Guys,

I'm trying to get http://asd.overcore.eu/ahoj.php (text: Zdravim) via SteamWorks..

Code:
  char buffer[64];
  Handle hdl = null;
  hdl = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, "www.asd.overcore.eu/ahoj.php");
  if(hdl == null)
  {
    PrintToChat(client, "Create HTTP Request - FAILED!");
    return;
  }
  if(SteamWorks_SendHTTPRequest(hdl))
  {
    SteamWorks_GetHTTPResponseBodyData(hdl, buffer, sizeof(buffer));
    PrintToChat(client, buffer);
  }
Probably I'm doing to wrong.. because i never used SteamWorks before..

Thanks in advance

Last edited by ESK0; 01-26-2016 at 13:18.
ESK0 is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 01-26-2016 , 17:09   Re: SteamWorks
Reply With Quote #2

Are you sure you want to send a POST request (k_EHTTPMethodPOST) ?
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 01-26-2016 , 17:27   Re: SteamWorks
Reply With Quote #3

Quote:
Originally Posted by pcmaster View Post
Are you sure you want to send a POST request (k_EHTTPMethodPOST) ?
Well i tried GET aswell
ESK0 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-26-2016 , 17:52   Re: SteamWorks
Reply With Quote #4

There really is not great documentaction available for steamworks, steamtools, andoes socket. Would be great if we could get a web/http thread going somewhere.

Would be even nicer if there was an official tcp/udp extension we can use as part of sm, along with wrappers and callbacks for http requests.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 01-26-2016 , 18:17   Re: SteamWorks
Reply With Quote #5

Quote:
Originally Posted by friagram View Post
There really is not great documentaction available for steamworks, steamtools, andoes socket. Would be great if we could get a web/http thread going somewhere.

Would be even nicer if there was an official tcp/udp extension we can use as part of sm, along with wrappers and callbacks for http requests.
Yeye Exactly.. this is hell..i gave up..
ESK0 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-26-2016 , 18:31   Re: SteamWorks
Reply With Quote #6

Check updater, it has code written for all methods for fetching files over http for each extension.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Disowned
Member
Join Date: Oct 2015
Old 01-26-2016 , 18:35   Re: SteamWorks
Reply With Quote #7

Quote:
Originally Posted by friagram View Post
There really is not great documentaction available for steamworks, steamtools, andoes socket. Would be great if we could get a web/http thread going somewhere.

Would be even nicer if there was an official tcp/udp extension we can use as part of sm, along with wrappers and callbacks for http requests.
It is possible to expose the interface of the Webternet extension, but I'd rather just have an updated version of the cURL extension compiled in. No need to make the process obscure when there's millions of guides out there on how to just use cURL directly and handle responses.

Problem being that it has to pass quality tests, which means including SDKHooks and threading to SM standards. If someone makes that, they will make life, and secure communications, easier for everyone.

EDIT: Doesn't require SDKHooks, derp.

Previous thread on it: https://forums.alliedmods.net/showthread.php?t=276675

Last edited by Disowned; 01-26-2016 at 18:53.
Disowned is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-26-2016 , 18:45   Re: SteamWorks
Reply With Quote #8

Quote:
Originally Posted by Disowned View Post
which means including SDKHooks[/url]
That is incorrect, asherkin meant that a lot of SM plugins required SDKHooks before the SM team decided to include SDKHooks into SM packages.

Last edited by WildCard65; 01-26-2016 at 18:46.
WildCard65 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-26-2016 , 18:45   Re: SteamWorks
Reply With Quote #9

Unfortunately curl has limitations. Udp support and raw tcp is often needed for things (as query, sending messages to other servers or irc).

there is a curl extension, but I have not used it.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 01-26-2016 at 18:46.
friagram is offline
Disowned
Member
Join Date: Oct 2015
Old 01-26-2016 , 19:08   Re: SteamWorks
Reply With Quote #10

There is the option of cURL or SteamTools when it comes to HTTP requests. Since you were doing SteamWorks, SteamTools should do the same for you. (Only supports TF2) There may be a bug where your console gets filled up with an odd error message, or that might just be me.

EDIT: Apparently SteamWorks is also a thing, and Steamtools doesn't work for what I'm assumming will be a CS plugin.

https://forums.alliedmods.net/showthread.php?t=170630

PHP Code:
#include <sourcemod>
#include <steamtools>

public OnPluginStart()
{
    
RegServerCmd("send"sendRequest);
}

public 
Action sendRequest(args) {
    
char[] sURL "http://asd.overcore.eu/ahoj.php ";

    
//Get custom handle
    
HTTPRequestHandle HTTPRequest Steam_CreateHTTPRequest(HTTPMethod_GETsURL);
    
//Set timeout to 10 seconds
    
Steam_SetHTTPRequestNetworkActivityTimeout(HTTPRequest10);
    
//Set a Get parameter, makes URL look like: http://asd.overcore.eu/ahoj.php?parameter=12345
    
Steam_SetHTTPRequestGetOrPostParameter(HTTPRequest"parameter""12345");
    
//Set a header value because we can
    
Steam_SetHTTPRequestHeaderValue(HTTPRequest"server""TestFuton");
    
//Initialize the request.
    
Steam_SendHTTPRequest(HTTPRequestuploadCallback5);
    
//Send the request to the front of the queue
    
Steam_PrioritizeHTTPRequest(HTTPRequest);
    return 
Plugin_Handled;
}

public 
uploadCallback(HTTPRequestHandle HTTPRequestbool requestSuccessfulHTTPStatusCode statusCodecontextData)  {

    if(!
requestSuccessful) {
        
PrintToServer("There was an error in the request");
        return;
    }

    if(
statusCode == HTTPStatusCode_OK) {
        
PrintToServer("The request returned new data, http code 200");
    } else if(
statusCode == HTTPStatusCode_NotModified) {
        
PrintToServer("The request did not return new data, but did not error, http code 304");
        return;
    } else if(
statusCode == HTTPStatusCode_NotFound) {
        
PrintToServer("The requested URL could not be found, http code 404");
        return;
    } else if(
statusCode == HTTPStatusCode_InternalServerError) {
        
PrintToServer("The requested URL had an internal error, http code 500");
        return;
    }

    
int headersize Steam_GetHTTPResponseHeaderSize(HTTPRequest"customreceivedheader");
    if(
headersize == -1) {
        
PrintToServer("received header 'customreceivedheader' does not exist");
    } else {
        
//If header exists, print its value.
        
char buffer[64];
        
Steam_GetHTTPResponseHeaderValue(HTTPRequest"customreceivedheader"buffer64);
        
PrintToServer(buffer);
    }

    
int bodysize Steam_GetHTTPResponseBodySize(HTTPRequest);
    
char newbuf[128];
    
Format(newbuf128"%d"bodysize);
    
PrintToServer(newbuf);

    
char bodybuffer[10000];
    if(
bodysize 10000) {
        
PrintToServer("The requested URL returned with more data than expected");
        return;
    }

    
Steam_GetHTTPResponseBodyData(HTTPRequestbodybuffer10000);
    
    
//Print successfull response to server.
    
PrintToServer(bodybuffer);

    
Steam_ReleaseHTTPRequest(HTTPRequest);


type in 'send', you should get your response.

Last edited by Disowned; 01-26-2016 at 19:18.
Disowned is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode