public void Run() { /* [email protected] * Added functionality for a TCP server open on a static port of 9088 - yes needs to be in a config with edit screen but my WPF skills are NIL. * If there is a TCP client connected then it will send key presses to a PC running the receiver * Otherwise it will send the keypresses to the local PC * * TCP code may need a clean up as I used a routine I have used many times and know it works * The TCP Server code was handy and a known quality * * The way I have done this is to just serialise the INPUT object and send over TCP. Seemed the easiest way to accomodate this feature quickly. */ try { // Only attempt to bind the keyboard server if not in the Profile Editor or similar editor application, // and only if not disabled in undocumented setting if (ConfigManager.Application.ConnectToServers && !ConfigManager.SettingsManager.LoadSetting("Helios", "DisableKeyboardServer", false)) { try { Socket Svrsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 9088); Svrsocket.Bind(localEndPoint); Svrsocket.Listen(10); Svrsocket.BeginAccept(ConnectSocketAsync, Svrsocket); } catch (SocketException se) { if (HandleSocketException(se)) { // Socket read timeout - ignore } else { Logger.Error("Keyboard Thread unable to Bind TCP port: " + se.Message, se); } } } while (true) { try { Poll(); } catch (ThreadInterruptedException) { // NOOP } } } catch (Exception ex) { Logger.Error(ex, "Fatal error in keyboard thread; program will exit"); ExceptionViewer.DisplayException(ex); throw; } }