mirror of
https://github.com/GittyMac/OpenFK.git
synced 2026-03-21 17:44:31 -05:00
Testing out sending/getting tns from server
This commit is contained in:
parent
e0aa3c3bde
commit
1538a1a049
|
|
@ -555,6 +555,26 @@ namespace OpenFK
|
|||
if (e.args.Contains("<netcommands"))
|
||||
{
|
||||
Debug.WriteLine("[Network] Netcommand called.");
|
||||
|
||||
string tnurl = "";
|
||||
if(e.args.Contains("<netcommands><save_level "))
|
||||
{
|
||||
XmlDocument request = new XmlDocument(); //e.args to xml
|
||||
request.LoadXml(e.args);
|
||||
XmlNodeList xnList = request.SelectNodes("/netcommands/save_level"); //filters xml to the load info
|
||||
foreach (XmlNode xn in xnList)
|
||||
{
|
||||
tnurl = xn.Attributes["tnurl"].Value;
|
||||
}
|
||||
|
||||
byte[] tn = File.ReadAllBytes(Directory.GetCurrentDirectory() + tnurl);
|
||||
|
||||
using(var client = new System.Net.WebClient())
|
||||
{
|
||||
client.UploadData(Host + tnurl, tn);
|
||||
}
|
||||
}
|
||||
|
||||
if (DebugOnline == true)
|
||||
{
|
||||
AS2Container.SetVariable("msg", HTTPPost(e.args, Host).ToString()); //Sends the result of the POST request. It's usually a command for the game to handle.
|
||||
|
|
@ -988,6 +1008,53 @@ namespace OpenFK
|
|||
}
|
||||
var response = (HttpWebResponse)request.GetResponse();
|
||||
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
|
||||
|
||||
string tnurl = "";
|
||||
|
||||
if(responseString.Contains("<get_level "))
|
||||
{
|
||||
XmlDocument xRequest = new XmlDocument(); //e.args to xml
|
||||
xRequest.LoadXml(responseString);
|
||||
XmlNodeList xnList = xRequest.SelectNodes("/get_level/level"); //filters xml to the load info
|
||||
foreach (XmlNode xn in xnList)
|
||||
{
|
||||
tnurl = xn.Attributes["tnurl"].Value;
|
||||
}
|
||||
|
||||
using (var client = new System.Net.WebClient())
|
||||
{
|
||||
client.DownloadFile(Host + tnurl, Directory.GetCurrentDirectory() + tnurl);
|
||||
}
|
||||
}
|
||||
else if (responseString.Contains("<get_top "))
|
||||
{
|
||||
XmlDocument xRequest = new XmlDocument(); //e.args to xml
|
||||
xRequest.LoadXml(responseString);
|
||||
XmlNodeList xnList = xRequest.SelectNodes("/get_top/levels/level"); //filters xml to the load info
|
||||
foreach (XmlNode xn in xnList)
|
||||
{
|
||||
tnurl = xn.Attributes["tnurl"].Value;
|
||||
using (var client = new System.Net.WebClient())
|
||||
{
|
||||
client.DownloadFile(Host + tnurl, Directory.GetCurrentDirectory() + tnurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (responseString.Contains("<get_sh_levels "))
|
||||
{
|
||||
XmlDocument xRequest = new XmlDocument(); //e.args to xml
|
||||
xRequest.LoadXml(responseString);
|
||||
XmlNodeList xnList = xRequest.SelectNodes("/get_sh_levels/levels/level"); //filters xml to the load info
|
||||
foreach (XmlNode xn in xnList)
|
||||
{
|
||||
tnurl = xn.Attributes["tnurl"].Value;
|
||||
using (var client = new System.Net.WebClient())
|
||||
{
|
||||
client.DownloadFile(Host + tnurl, Directory.GetCurrentDirectory() + tnurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return responseString;
|
||||
}
|
||||
//
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.0.0.0")]
|
||||
[assembly: AssemblyVersion("2.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.1.0.0")]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user