/// <summary> /// Invite a certain user to a personal chat /// </summary> /// <param name="user">The reference to the user with whom we want to chat</param> private void InviteUser(RemoteReference user) { System.Diagnostics.Debug.WriteLine("Inviting user"); user.AsyncInvoke("Invite", this.myServicePublication.serviceIdentifier); this.UIDispatcher(() => this.ShowMessageBox_OK(string.Format(this.inviteSuccessful_message, this.currentPartnerModel.nickname), this.inviteSuccessful_title)); }
/// <summary> /// Event handler which is to be triggered when a chat user has been discovered on the network /// </summary> /// <param name="userReference">The identifier of the chat user</param> private void UserListener_IsDiscovered(RemoteReference userReference) { FutureListener<string> nameListener = new FutureListener<string>(); // Get his name and store it locally - this is very useful for further operations (otherwise we'd have to ask him every time -> network delays) nameListener.IsResovled += (string name) => { this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => MyChatUsersViewModel.AddChatUser(userReference.guid, name)); this.chatUsers.Add(userReference.guid, userReference); }; Future future = userReference.AsyncInvoke("GetName"); future.When(nameListener); }
/// <summary> /// Join the chat with a certain user. Will change switch to the communication page. /// </summary> /// <param name="partner">Partner with whom we want to chat</param> /// <param name="partnerModel">The model of our current partner</param> /// private void JoinChat(RemoteReference partner, ChatUserModel partnerModel) { this.currentPartner = partner; this.currentPartnerModel = partnerModel; partner.AsyncInvoke("EnteredChatNotification", this.myChatUser.GetName()); Frame.Navigate(typeof(CommunicationPage), new PageInformation(partner, partnerModel.nickname, this.myChatUser)); }
/// <summary> /// Join the chat with a certain user. Will change switch to the communication page. /// </summary> /// <param name="partner">Partner with whom we want to chat</param> /// <param name="partnerModel">The model of our current partner</param> private void JoinChat(RemoteReference partner, ChatUserModel partnerModel) { this.currentPartner = partner; this.currentPartnerModel = partnerModel; PhoneApplicationService.Current.State["CurrentPartner"] = partner; PhoneApplicationService.Current.State["PartnerNickname"] = partnerModel.nickname; PhoneApplicationService.Current.State["MyChatUser"] = this.myChatUser; partner.AsyncInvoke("EnteredChatNotification", this.myChatUser.GetName()); NavigationService.Navigate(communicationPageURI); }