/// <summary> /// Listen to local event and send it to the server if needed /// (ex: listen to game invitation) /// </summary> public void HandleOnlineEvent(IEvent localEvent) { var sessionEvent = localEvent as AbstractSessionEvent; if (sessionEvent != null && !sessionEvent.SendToServer) { var invitation = sessionEvent as InvitationEvent; // Can't receive invitation if already in game if (invitation != null) { if (invitation.InvitedPlayerId == Profile.Instance.CurrentProfile.UserHashId && !StateManager.Instance.IsGameRunning()) { try { var context = new GameInvitationViewModel(invitation); var invitationPopup = new GameInvitation(context); invitationPopup.ShowDialog(); } catch (Exception) { Console.WriteLine("Received a game that does not exist"); } } } } }
public GameInvitation(GameInvitationViewModel context) { InitializeComponent(); DataContext = context; if (context.CloseAction == null) { context.CloseAction = new Action(this.Close); } }