Beispiel #1
0
        public async Task GroupChatTest()
        {
            IGroupChatManager chatManager1 = client1.ChatXmppClient.GetGroupChatManager(groupJid, groupDialogId);

            chatManager1.JoinGroup(id1.ToString());
            IGroupChatManager chatManager2 = client2.ChatXmppClient.GetGroupChatManager(groupJid, groupDialogId);

            chatManager2.JoinGroup(id2.ToString());
            IGroupChatManager chatManager3 = client3.ChatXmppClient.GetGroupChatManager(groupJid, groupDialogId);

            chatManager3.JoinGroup(id3.ToString());
            await Task.Delay(2000);

            chatManager1.SendMessage("One reports to the group.");
            await Task.Delay(1000);

            chatManager2.SendMessage("Three reports to the group");
            await Task.Delay(1000);

            chatManager3.SendMessage("Three reports to the group");
            await Task.Delay(1000);

            Debug.WriteLine("############ Updating name");
            string newName             = "Name1";
            var    updateDialogRequest = new UpdateDialogRequest {
                DialogId = groupDialogId
            };

            updateDialogRequest.Name = newName;
            var updateDialogResponse = await client2.ChatClient.UpdateDialogAsync(updateDialogRequest);

            Assert.AreEqual(updateDialogResponse.StatusCode, HttpStatusCode.OK);

            chatManager2.NotifyGroupNameChanged(newName, DateTime.Now);
            await Task.Delay(1000);

            Debug.WriteLine("############ Checking messaging again");

            chatManager1.SendMessage("One reports to the group.");
            await Task.Delay(1000);

            chatManager2.SendMessage("Three reports to the group");
            await Task.Delay(1000);

            chatManager3.SendMessage("Three reports to the group");
            await Task.Delay(1000);

            await Task.Delay(3000);
        }
Beispiel #2
0
        public async Task SendMessageTest()
        {
            Message lastClient2Message = null;

            var createDialogResponse = await client1.ChatClient.CreateDialogAsync("TestDialog1", DialogType.Group, string.Format("{0},{1}", id2, "3125358"));

            Assert.AreEqual(createDialogResponse.StatusCode, HttpStatusCode.Created);

            IGroupChatManager chatManager1 = client1.ChatXmppClient.GetGroupChatManager(createDialogResponse.Result.XmppRoomJid, createDialogResponse.Result.Id);
            IGroupChatManager chatManager2 = client2.ChatXmppClient.GetGroupChatManager(createDialogResponse.Result.XmppRoomJid, createDialogResponse.Result.Id);

            chatManager1.JoinGroup(id1.ToString());
            chatManager2.JoinGroup(id2.ToString());

            await Task.Delay(3000);

            string messageText = "Group test message";

            chatManager2.SendMessage(messageText);

            await Task.Delay(5000);
        }
        private async Task Initialize(string dialogId)
        {
            IsLoading = true;

            var dialogManager = ServiceLocator.Locator.Get<IDialogsManager>();
            dialog = dialogManager.Dialogs.FirstOrDefault(d => d.Id == dialogId);

            if (dialog == null) return;

            currentUserId = SettingsManager.Instance.ReadFromSettings<int>(SettingsKeys.CurrentUserId);

            ChatName = dialog.Name;
            ChatImage = dialog.Image;
            NumberOfMembers = dialog.OccupantIds.Count;

            await QmunicateLoggerHolder.Log(QmunicateLogLevel.Debug, string.Format("Initializing GroupChat page. CurrentUserId: {0}. Group JID: {1}.", currentUserId, dialog.XmppRoomJid));

            await MessageCollectionViewModel.LoadMessages(dialogId);

            groupChatManager = QuickbloxClient.ChatXmppClient.GetGroupChatManager(dialog.XmppRoomJid, dialog.Id);
            groupChatManager.MessageReceived += ChatManagerOnOnMessageReceived;
            groupChatManager.JoinGroup(currentUserId.ToString());

            IsLoading = false;
        }