private void M_deviceSocketConnection_OnMessageReceived(object sender, BaseMessage e) { var dontWait = SimpleDispatcher.RunAsync(delegate { try { if (e is MothershipSendCardMessage) { var cardMessage = e as MothershipSendCardMessage; var card = CrossPlatformCardViewModel.CreateInstanceFunction(); card.CardIdentifier = cardMessage.CardIdentifier; card.CardJson = cardMessage.CardJson; MainViewModel.Current.AddCard(card); } else if (e is ClientNameAssignedMessage) { MainViewModel.Current.Name = (e as ClientNameAssignedMessage).ClientName; m_onNameAssignedAction?.Invoke(); } else if (e is MothershipDisconnectedMessage) { OnConnectionClosed?.Invoke("Mothership has been disconnected"); } } catch { } }); }
private void DeviceSocketConnection_OnMessageReceived(object sender, BaseMessage e) { var dontWait = SimpleDispatcher.RunAsync(delegate { OnMessageReceived(e); }); }
private void DeviceSocketConnection_OnSocketClosed(object sender, EventArgs e) { var dontWait = SimpleDispatcher.RunAsync(async delegate { await new MessageDialog("Connection closed. Please re-open the app.").ShowAsync(); Application.Current.Exit(); }); }
private void M_deviceSocketConnection_OnSocketClosed(object sender, EventArgs e) { m_deviceSocketConnection.OnSocketClosed -= M_deviceSocketConnection_OnSocketClosed; m_deviceSocketConnection.OnMessageReceived -= M_deviceSocketConnection_OnMessageReceived; m_deviceSocketConnection = null; var dontWait = SimpleDispatcher.RunAsync(delegate { try { OnConnectionClosed?.Invoke("Socket closed"); } catch { } }); }