Raised This Month: $119 Target: $400
 29% 

[ANY] SteamWorks


Post New Thread Reply   
 
Thread Tools Display Modes
ReymonARG
Junior Member
Join Date: Jun 2017
Old 09-26-2017 , 16:46   Re: [ANY] SteamWorks
Reply With Quote #621

Quote:
Originally Posted by KyleS View Post
Can't you just set the headers?

Yes but how I still connected to the host?
I can't send 70mb file with SteamWorks_SetHTTPRequestRawPostBody at one.

Now i split and send multipart like real multipart will do.

EDIT:
I forgot to post a sample code... now I'm doing a fake multipart (with redis in the server i handle the parts)
the idea is to use the multipart protocol

Code:
#include <sourcemod>
#include <SteamWorks>


public Plugin myinfo = 
{
	name = "MultiPart",
	author = "Ramón Berrutti <Reymon>",
	description = "MultiPart test",
	version = "1.0",
	url = "https://ramonberrutti.com"
};

public void OnPluginStart()
{
	RegServerCmd("multipart_test",    OnConsole_multipart_test,     "Test MultiPart");
}


public Action OnConsole_multipart_test(int args)
{
	File file = OpenFile("ebacon2__round06.txt", "r");

	UploadFile( file );

	return Plugin_Handled;
}

void UploadFile(File file)
{

	if( file.EndOfFile() )
	{
		file.Close();
		return;
	}


	char buffer[1024];
	if(!file.EndOfFile() && file.ReadString(buffer, sizeof(buffer)))
    {
		Handle req = SteamWorks_CreateHTTPRequest( k_EHTTPMethodPOST, "http://localhost:3000/api/backups");
		SteamWorks_SetHTTPCallbacks(req, RequestCallback);

		SteamWorks_SetHTTPRequestContextValue(req, file);

		char buffer2[2048];
		FormatEx(buffer2, sizeof(buffer2), "--%s\r\nContent-Disposition: form-data; name=\"file\"; filename=\"test.txt\"\r\nContent-Type: text/plain\r\n\r\n%s", "AaB03x", buffer);

		// If file finish add the finish part
		/*if( file.EndOfFile() )
		{
			Format(buffer2, sizeof(buffer2), "%s\r\n--%s--", buffer2, "AaB03x");
		}*/

		Format(buffer2, sizeof(buffer2), "%s\r\n--%s--", buffer2, "AaB03x");

		PrintToServer("New Part Size:%i -->\n%s", strlen(buffer2), buffer2);

		SteamWorks_SetHTTPRequestRawPostBody(req, "multipart/form-data; boundary=AaB03x", buffer2, strlen(buffer2));
		SteamWorks_SendHTTPRequest(req);
    }
}


public int RequestCallback(Handle request, bool failure, bool requestSuccessful, EHTTPStatusCode statusCode, File file) 
{
	//PrintToServer("%i) Failure: %i RquestSuccessful: %i Status: %i", count, failure, requestSuccessful, statusCode);

	if( requestSuccessful && statusCode == k_EHTTPStatusCode200OK )
	{
		UploadFile(file);
	}
}

Last edited by ReymonARG; 09-26-2017 at 17:52.
ReymonARG is offline
stickz
Senior Member
Join Date: Oct 2012
Location: Ontario, Canada
Old 10-16-2017 , 13:47   Re: [ANY] SteamWorks
Reply With Quote #622

I just crashed my game-server with this extension.
https://crash.limetech.org/4bn2qkvblmcg

I updated to the latest version while it was running, then it crashed when the map changed.
stickz is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 10-16-2017 , 14:05   Re: [ANY] SteamWorks
Reply With Quote #623

Quote:
Originally Posted by stickz View Post
I updated to the latest version while it was running, then it crashed when the map changed.
What exactly did you expect to happen? It isn't safe to replace binaries while the server is running.
__________________
asherkin is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 10-16-2017 , 15:12   Re: [ANY] SteamWorks
Reply With Quote #624

Quote:
Originally Posted by stickz View Post
I just crashed my game-server with this extension.
https://crash.limetech.org/4bn2qkvblmcg

I updated to the latest version while it was running, then it crashed when the map changed.
This command exists exactly to help prevent that: https://linux.die.net/man/1/install
KyleS is offline
Reply


Thread Tools
Display Modes

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:42.


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