public MainApplicationContext(int port) { // init tray icon var menuItems = new MenuItem[] { new MenuItem("Exit", Exit), }; trayIcon = new NotifyIcon() { Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location), ContextMenu = new ContextMenu(menuItems), Visible = true, Text = "Remote Desktop Server v0.1.0" }; // init input simulation input = new InputSimulator(); // star socket dispatcher = Dispatcher.CurrentDispatcher; socket = new DataSocket(NetworkTypes.Server); socket.ConnectedCallback += Socket_ConnectedCallback; socket.DisconnectedCallback += Socket_DisconnectedCallback; socket.ConnectionFailedCallback += Socket_ConnectionFailedCallback; socket.DataRecievedCallback += Socket_DataRecievedCallback; socket.StartDataRecievedCallback += Socket_StartDataRecievedCallback; socket.EndDataRecievedCallback += Socket_EndDataRecievedCallback; socket.Listen(IPAddress.Any, port); // start network discovery networkDiscovery = new NetworkDiscovery(NetworkTypes.Server); networkDiscovery.Register("SimpleRemoteDesktop", port); }