| 1234567891011121314151617181920212223242526272829303132333435363738394041 | using System.Net;using System.Net.Sockets;using System.Text;using Comal.Classes;using InABox.Clients;using InABox.Core;namespace PRSServer{    internal class AutoDiscoveryEngine : Engine<AutoDiscoveryServerProperties>    {        public override void Run()        {            var settings = new AutoDiscoverySettings();            settings.Name = Properties.DisplayName;            settings.URL = Properties.ServerURL;            settings.Port = Properties.ServerPort;            settings.Protocol = SerializerProtocol.Rest;            settings.LibraryLocation = Properties.LibraryLocation;            settings.GoogleAPIKey = Properties.GoogleAPIKey;            var responseData = Encoding.ASCII.GetBytes(Serialization.Serialize(settings));            while (true)            {                var server = new UdpClient(8888);                var clientEp = new IPEndPoint(IPAddress.Any, 0);                var clientRequestData = server.Receive(ref clientEp);                Logger.Send(LogType.Information, "", string.Format("Processing Request from {0}", clientEp));                //var clientRequest = Encoding.ASCII.GetString(clientRequestData);                //Logger.Send(LogType.Information, "", String.Format("- Request: {0}", clientRequest));                server.Send(responseData, responseData.Length, clientEp);                Logger.Send(LogType.Information, "", string.Format("- Sending: {0} bytes", responseData.Length));                server.Close();                Logger.Send(LogType.Information, "", "- Closed");            }        }        public override void Stop()        {        }    }}
 |