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 MainWindow() { if (Singleton != null) { throw new Exception("MainWindow Singleton Exception"); } Singleton = this; AllowClose = false; InitializeComponent(); InitializeSize(); // Timed delayed Show() _showMe.Interval = new TimeSpan(0, 0, 0, 0, 200); _showMe.Tick += showMe_Tick; _showMe.Start(); // Not sure why I put this here, but it doesn't hurt anything LocalSetting.Update(); #if !DEMO // Start the client broadcast server if running locally if (BroadcastServerSocket.IsEnabled) { BroadcastServerSocket.Start(); } // Start the client broadcast client BroadcastClientSocket.Connected += MessageSocket_Connected; BroadcastClientSocket.ReceivedMessage += MessageSocket_ReceivedMessage; BroadcastClientSocket.Start(); #endif // Restore focus if lost LostFocus += MainWindowDialog_LostFocus; }
void BroadcastServerSocket_StartedListening(object sender, EventArgs e) { if (BroadcastClientSocket.IsConnected) { BroadcastClientSocket.Stop(); } BroadcastClientSocket.Start(); }