I've worked on the OnlineStatistics (Further informations) this evening and manage to send post request to Ash's server.
Ash is the person in charge of creating DataRun Website, he provided us a test page to send post and get request at the following address: http://kyuu.co.uk/datarun.php
If you enter the following url for example http://kyuu.co.uk/da...hp?game=dataRun
the web browser will displayed
post vars get vars "game" = dataRun
The Objective was to send this kind of request using TcpLink UnrealScript class and here is the code which do that:
Use Class
var DataRun_TcpLink wConn; wConn = spawn(class'DataRun_TcpLink'); wConn.sendPlayerStat("1664", "BeerLand", "124", "51");
TCPLink Class
class DataRun_TcpLink extends TcpLink config(DataRun); var config String ipWebSite, urlWebSite, pathFile; var config int portNumber; var IpAddr ipA; function PostBeginPlay() { super.PostBeginPlay(); StringToIpAddr(ipWebSite, ipA); ipA.Port = portNumber; BindPort(); // receive events rather than get data manually ReceiveMode = EReceiveMode.RMODE_Event; //method receiveText call LinkMode = ELinkMode.MODE_Text; } /* Send a Post Request as follow POST /datarun.php HTTP/1.0 From: xiongmao@datarun.com User-Agent: HTTPTool/1.0 Content-Type: application/x-www-form-urlencoded Content-Length: 27 [Blank Line] userid=xiongmao&password=guessme */ function sendPlayerStat(String playerID, String level, String totalTime, String energy) { local String httpRequest, request; request = getRequest(playerID, level, totalTime, energy); httpRequest = getStandardHeader(); httpRequest $= getContentLength(request); httpRequest $= Chr(13)$Chr(10); // add the blank line httpRequest $= request; if(!IsConnected()) Open(ipA); SendText(httpRequest); } function String getStandardHeader() { local String header; //set the path of the file which will receive the post request header = "POST /"$pathFile$" HTTP/1.0"$Chr(13)$Chr(10); //set the sender (optional) header $= "From: xiongmao@datarun.com"$Chr(13)$Chr(10); //set user agent header $= "User-Agent: HTTPTool/1.0"$Chr(13)$Chr(10); //set encode type header $= "Content-Type: application/x-www-form-urlencoded"$Chr(13)$Chr(10); return header; } function String getContentLength(String request) { local String cLength; cLength = "Content-Length: "$len(request)$Chr(13)$Chr(10); return cLength; } function String getRequest(String playerID, String level, String totalTime, String energy) { local String request; request = "playerID="$playerID$"&level="$level$"&totalTime="$totalTime$"&energy="$energy; return request; } event ReceivedText( string Text ) { LogInternal("text: "$Text); } defaultproperties { pathFile = "datarun.php" ipWebSite = "82.17.97.168" urlWebSite = "http://kyuu.co.uk" portNumber = 80 }
and you will see a great trace in your logfile:
HTTP/1.1 200 OK Date: Mon, 05 May 2008 22:11:59 GMT Server: Apache X-Powered-By: PHP/5.2.6RC1-pl1-gentoo Content-Length: 493 Connection: close Content-Type: text/html <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>kyuu</title> </head> <body> <h1>post vars</h1> <ul> <li>"playerID" = 1664</li><li>"level" = BeerLand</li><li>"totalTime" = 124</li><li>"energy" = 51</li></ul> <h1>get vars</h1> </body> </html>
I can't figure out how to find gameSpyId if anyone has a clue ? if not players will have to create a kind of account on the website.
I don't know if it's necessary to take care of receive message (maybe the first line to see if the request has succeeded)
Comment? questions?