using Quasar.Common.Messages; using Quasar.Common.Networking; using System; using System.Collections.Generic; using xServer.Core.Networking; namespace xServer.Core.Commands { public class SystemInformationHandler : MessageProcessorBase>> { /// /// The client which is associated with this system information handler. /// private readonly Client _client; /// /// Initializes a new instance of the class using the given client. /// /// The associated client. public SystemInformationHandler(Client client) : base(true) { _client = client; } /// public override bool CanExecute(IMessage message) => message is GetSystemInfoResponse; /// public override bool CanExecuteFrom(ISender client) => _client.Equals(client); /// public override void Execute(ISender sender, IMessage message) { switch (message) { case GetSystemInfoResponse info: Execute(sender, info); break; } } /// /// Refreshes the system information of the client. /// public void RefreshSystemInformation() { _client.Send(new GetSystemInfo()); } private void Execute(ISender client, GetSystemInfoResponse message) { OnReport(message.SystemInfos); // TODO: Refactor tooltip //if (Settings.ShowToolTip) //{ // var builder = new StringBuilder(); // for (int i = 0; i < packet.SystemInfos.Length; i += 2) // { // if (packet.SystemInfos[i] != null && packet.SystemInfos[i + 1] != null) // { // builder.AppendFormat("{0}: {1}\r\n", packet.SystemInfos[i], packet.SystemInfos[i + 1]); // } // } // FrmMain.Instance.SetToolTipText(client, builder.ToString()); //} } protected override void Dispose(bool disposing) { } } }