2015-05-16 01:15:44 +00:00
|
|
|
|
using System;
|
2015-06-01 09:44:48 +00:00
|
|
|
|
using System.IO;
|
2015-05-16 01:15:44 +00:00
|
|
|
|
using System.Windows.Forms;
|
2015-06-05 21:07:37 +00:00
|
|
|
|
using xServer.Core.Networking;
|
2015-05-16 01:15:44 +00:00
|
|
|
|
using xServer.Core.Packets.ClientPackets;
|
|
|
|
|
using xServer.Forms;
|
|
|
|
|
using xServer.Settings;
|
|
|
|
|
|
|
|
|
|
namespace xServer.Core.Commands
|
|
|
|
|
{
|
|
|
|
|
/* THIS PARTIAL CLASS SHOULD CONTAIN METHODS THAT MANIPULATE THE CONNECTION. */
|
|
|
|
|
public static partial class CommandHandler
|
|
|
|
|
{
|
|
|
|
|
public static void HandleInitialize(Client client, Initialize packet)
|
|
|
|
|
{
|
2015-06-05 16:40:15 +00:00
|
|
|
|
if (client.EndPoint.Address.ToString() == "255.255.255.255" || packet.Id.Length != 64)
|
2015-05-16 01:15:44 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2015-05-29 21:34:57 +00:00
|
|
|
|
try
|
2015-05-16 01:15:44 +00:00
|
|
|
|
{
|
2015-05-29 21:34:57 +00:00
|
|
|
|
client.Value.Version = packet.Version;
|
|
|
|
|
client.Value.OperatingSystem = packet.OperatingSystem;
|
|
|
|
|
client.Value.AccountType = packet.AccountType;
|
|
|
|
|
client.Value.Country = packet.Country;
|
|
|
|
|
client.Value.CountryCode = packet.CountryCode;
|
|
|
|
|
client.Value.Region = packet.Region;
|
|
|
|
|
client.Value.City = packet.City;
|
|
|
|
|
client.Value.Id = packet.Id;
|
2015-05-31 17:22:00 +00:00
|
|
|
|
client.Value.Username = packet.Username;
|
|
|
|
|
client.Value.PCName = packet.PCName;
|
2015-05-16 01:15:44 +00:00
|
|
|
|
|
2015-06-01 09:44:48 +00:00
|
|
|
|
string userAtPc = string.Format("{0}@{1}", client.Value.Username, client.Value.PCName);
|
|
|
|
|
|
2015-06-01 16:50:20 +00:00
|
|
|
|
client.Value.DownloadDirectory = (!Helper.Helper.CheckPathForIllegalChars(userAtPc)) ?
|
2015-06-05 16:40:15 +00:00
|
|
|
|
Path.Combine(Application.StartupPath, string.Format("Clients\\{0}_{1}\\", userAtPc, client.Value.Id.Substring(0, 7))) :
|
|
|
|
|
Path.Combine(Application.StartupPath, string.Format("Clients\\{0}_{1}\\", client.EndPoint.Address, client.Value.Id.Substring(0, 7)));
|
2015-06-01 09:44:48 +00:00
|
|
|
|
|
2015-07-12 17:30:34 +00:00
|
|
|
|
FrmMain.Instance.ConServer.CountAllTimeConnectedClientById(client.Value.Id);
|
2015-05-16 01:15:44 +00:00
|
|
|
|
|
2015-05-29 21:34:57 +00:00
|
|
|
|
string country = string.Format("{0} [{1}]", client.Value.Country, client.Value.CountryCode);
|
2015-05-16 01:15:44 +00:00
|
|
|
|
|
2015-05-31 18:36:40 +00:00
|
|
|
|
// this " " leaves some space between the flag-icon and first item
|
2015-05-29 21:34:57 +00:00
|
|
|
|
ListViewItem lvi = new ListViewItem(new string[]
|
|
|
|
|
{
|
2015-05-31 18:36:40 +00:00
|
|
|
|
" " + client.EndPoint.Address.ToString(), client.EndPoint.Port.ToString(),
|
2015-06-01 09:44:48 +00:00
|
|
|
|
userAtPc, client.Value.Version, "Connected", "Active", country,
|
|
|
|
|
client.Value.OperatingSystem, client.Value.AccountType
|
2015-05-29 21:34:57 +00:00
|
|
|
|
}) { Tag = client, ImageIndex = packet.ImageIndex };
|
2015-05-16 01:15:44 +00:00
|
|
|
|
|
2015-05-29 21:34:57 +00:00
|
|
|
|
FrmMain.Instance.AddClientToListview(lvi);
|
2015-05-16 01:15:44 +00:00
|
|
|
|
|
2015-05-29 21:34:57 +00:00
|
|
|
|
if (XMLSettings.ShowPopup)
|
|
|
|
|
FrmMain.Instance.ShowPopup(client);
|
2015-05-16 01:15:44 +00:00
|
|
|
|
|
2015-05-29 21:34:57 +00:00
|
|
|
|
client.Value.IsAuthenticated = true;
|
2015-06-11 08:19:42 +00:00
|
|
|
|
if (XMLSettings.ShowToolTip)
|
|
|
|
|
new Packets.ServerPackets.GetSystemInfo().Execute(client);
|
2015-05-29 21:34:57 +00:00
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
2015-05-16 01:15:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HandleStatus(Client client, Status packet)
|
|
|
|
|
{
|
2015-07-09 19:16:21 +00:00
|
|
|
|
FrmMain.Instance.SetStatusByClient(client, packet.Message);
|
2015-05-16 01:15:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HandleUserStatus(Client client, UserStatus packet)
|
|
|
|
|
{
|
2015-07-09 19:16:21 +00:00
|
|
|
|
FrmMain.Instance.SetUserStatusByClient(client, packet.Message);
|
2015-05-16 01:15:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|