void MessageSocket_ReceivedMessage(object sender, EventArgs e) { var message = sender as string; if (message == null) { return; } if (message.Equals("ServerPortMayHaveChanged")) { // Restart the client BroadcastClientSocket.Stop(); BroadcastClientSocket.Start(); } else if (message.StartsWith("UpdateServerInfo ")) { string[] tokens = message.Split(' '); if (tokens.Length != 3) { return; } LocalSetting.Values.String["UpdateServerPort"] = tokens[2]; LocalSetting.Values.String["UpdateServer"] = tokens[1]; LocalSetting.Update(); } }
public static void ShutdownApplication(bool showTaskbar = true) { IsAppShuttingDown = true; LocalSetting.Update(); #if !DEMO if (LocalSetting.Values.String["StartBroadcastServer"] != null) { BroadcastServerSocket.Stop(); } BroadcastClientSocket.Stop(); #endif if (TaskManagerServiceHelper.IsStarted) { TaskManagerServiceHelper.IsTaskManagerDisabled = false; } if (ConfigurationManager.UseKeyboardHook) { UserControlManager.Disable(); } if (showTaskbar) { UserControlManager.ShowTaskbar(true); } Logger.WriteLog("Exiting application"); Logger.CloseLog(); TemPOS.MainWindow.Singleton.AllowClose = true; TemPOS.MainWindow.Singleton.Dispatcher.Invoke((Action)(() => { TemPOS.MainWindow.Singleton.Closed += SingletonClosed; TemPOS.MainWindow.Singleton.Close(); })); }
void BroadcastServerSocket_StartedListening(object sender, EventArgs e) { if (BroadcastClientSocket.IsConnected) { BroadcastClientSocket.Stop(); } BroadcastClientSocket.Start(); }