2017-03-21 8 views
0

webRTC 앱에 채팅 클라이언트를 추가하고 채팅방이없는 경우 문제가 발생합니다. 한 사용자가 로그인하여 대화방에 특정 이름이 있는지 확인합니다. 존재하지 않으면 사용자가 만듭니다. 두 번째 사용자가 동일한 채팅방 이름으로 로그인하여 검색하고 QB.chat.dialog.list ({name : 'stringWithMyChatRoomName'})로 검색하지만 첫 번째 사용자 이후에도 문제가 발생합니다. 방금 결과로 반환되지 않는 방을 만들었습니다. 나는 DB에서 구성된다는 것을 알기 위해 관리자의 방을 볼 수 있습니다. 현재 결과가 부족한 코드는 다음과 같습니다.Quickblox Javascript SDK + Angular + webRTC - 다른 사용자가 만든 후에 이름별로 채팅방 필터가 표시되지 않습니다.

QB.createSession(function(err,result){ 
    if (result) { 
     QB.login($scope.userParams, function(loginErr, loginUser){ 
      if (loginUser) { 
       console.log('Logged in as:'); 
       console.log(loginUser); 
       QB.users.update($scope.userParams.id, {tag_list: $scope.userParams.tag_list}, function(err, user){ 
        if (user) { 
         console.log('updated room'); 
         //console.log(user); 
        }else if (err) { 
         console.log('Didn\'t update room'); 
         //console.log(err); 
        } 
        QB.chat.connect({ 
         userId: $scope.userParams.id, 
         password: $scope.userParams.password, 
         login: $scope.userParams.full_name 
        }, function(err, result) { 
         if (result) { 
          console.log($scope.userParams.tag_list); 
          //$scope.userParams.user_tags = $scope.userParams.tag_list; 
          //$scope.updatePeerList(); 
          var filters = {type: 2,name: $scope.userParams.tag_list}; 
          //var filters = {name: $scope.userParams.tag_list} 
          QB.chat.dialog.list(filters, function(err, resDialogs) { 
           if (resDialogs) { 
            console.log(resDialogs); 
            if (resDialogs.total_entries === 0) { 
             QB.chat.dialog.create({ 
              type: 2, 
              name: $scope.userParams.tag_list 
             }, function(err, createdDialog) { 
              if (createdDialog) { 
               console.log(createdDialog); 
               QB.chat.muc.join(createdDialog.xmpp_room_jid, function() { 

               }); 
              } else { 
               console.log(err); 
              } 
             }); 
            }else { 
             angular.forEach(resDialogs.items, function(item, i, arr) { 
              console.log('item found'); 
              console.log(item); 
              $scope.chatSession = item; 

              // join room 
              if ($scope.chatSession.type !== 3) { 
               QB.chat.muc.join($scope.chatSession.xmpp_room_jid, function() { 

               }); 
              } 
              //$scope.occupants = []; 
              $scope.chatSession.occupants_ids.map(function(userId) { 
               if ($scope.userParams.id !== userId && $scope.occupants.indexOf(userId) < 1) { 
                $scope.occupants.push(userId); 
               } 
              }); 

              angular.forEach($scope.occupants, function (user_id) { 
               if (user_id !== $scope.userParams.id) { 
                var msg = { 
                 type: 'chat', 
                 extension: { 
                  notification_type: 1, 
                  _id: $scope.chatSession.xmpp_room_jid, 
                  name: $scope.userParams.full_name, 
                  occupant: $scope.userParams.id 
                 } 
                }; 
                console.log(user_id); 
                QB.chat.send(user_id, msg); 
               } 
              }); 
             }); 
             console.log('scope apply occupants and chatSession'); 
             $scope.$apply(); 
            } 
           } else { 
            console.log('error with chat.dialog.list'); 
            console.log(err); 
           } 
          });             
         } else { 
          console.log('chat.connect failed'); 
          console.log(res); 
         } 
        }); 
       }); 
      }else { 
       console.log('log in error'); 
       console.log(loginErr); 
      } 
     }); 
    }else if (err) { 
     console.log('Error creating session'); 
     console.log(err); 
    } 
}); 

이제 모든 그룹 기간에 대한 검색을 시도했지만 0도 반환합니다. 내가 공개 그룹을 만들려고 노력했지만 QB는 방 안에있는 사람들의 사용자 ID를 표시하지 않으므로 사용자 ID가없는 사용자에게 메시지를 보낼 수있는 방법이 없습니다.

원하는 효과를 얻는 방법에 대해 조언하십시오. 고맙습니다.

답변