Mainly cosmetic changes.
This commit is contained in:
+6
-39
@@ -20,10 +20,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
namespace pokerth_console
|
||||
@@ -32,44 +28,15 @@ namespace pokerth_console
|
||||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
// Retrieve server list.
|
||||
WebClient webcl = new WebClient();
|
||||
string tmpFilePath = Path.GetTempPath();
|
||||
string tmpZipFileName = tmpFilePath + "pokerth_serverlist.xml.z";
|
||||
string tmpXmlFileName = tmpFilePath + "pokerth_serverlist.xml";
|
||||
webcl.DownloadFile("http://pokerth.net/serverlist.xml.z", tmpZipFileName);
|
||||
ZlibHelper.UncompressFile(tmpZipFileName, tmpXmlFileName);
|
||||
FileStream f = new FileStream(tmpXmlFileName, FileMode.Open, FileAccess.Read);
|
||||
XmlReader x = XmlReader.Create(f);
|
||||
x.Read();
|
||||
x.ReadStartElement("ServerList");
|
||||
x.ReadStartElement("Server");
|
||||
x.ReadToFollowing("IPv4Address");
|
||||
x.MoveToFirstAttribute();
|
||||
string ipAddress = x.Value;
|
||||
x.ReadToFollowing("Port");
|
||||
x.MoveToFirstAttribute();
|
||||
int port = Convert.ToInt32(x.Value);
|
||||
x.Close();
|
||||
f.Close();
|
||||
File.Delete(tmpZipFileName);
|
||||
File.Delete(tmpXmlFileName);
|
||||
// Connect to the server.
|
||||
TcpClient client = new TcpClient(ipAddress, port);
|
||||
NetPacket test = new NetPacketInit();
|
||||
test.Properties.Add(NetPacket.PropertyType.PropRequestedVersionMajor, "4");
|
||||
test.Properties.Add(NetPacket.PropertyType.PropRequestedVersionMinor, "2");
|
||||
test.Properties.Add(NetPacket.PropertyType.PropPlayerName, "Loto");
|
||||
test.Properties.Add(NetPacket.PropertyType.PropPlayerPassword, "");
|
||||
byte[] buf = test.ToByteArray();
|
||||
client.GetStream().Write(buf, 0, buf.Length);
|
||||
Settings settings = new Settings();
|
||||
GameInfoList list = new GameInfoList();
|
||||
ReceiverThread t = new ReceiverThread(client.GetStream(), list);
|
||||
ReceiverThread.Run(t);
|
||||
Client client = new Client(settings);
|
||||
client.Connect();
|
||||
client.Start(list);
|
||||
Thread.Sleep(5000);
|
||||
t.SetTerminateFlag();
|
||||
client.SetTerminateFlag();
|
||||
Console.Write(list.ToString());
|
||||
t.WaitTermination();
|
||||
client.WaitTermination();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user