Exemplo n.º 1
0
        private static void SetupRooms(PersistentChatEndpoint persistentChatEndpoint)
        {
            string chatRoomName = "SampleRiamo_Room" + TestRunUniqueId;

            // Get a category
            Uri catUri = SampleCommon.GetCategoryUri(persistentChatEndpoint);

            // Create a new chat room
            Uri roomUri = SampleCommon.RoomCreateUnderNonRootCategory(persistentChatEndpoint, catUri, chatRoomName);

            PersistentChatUserServices userMgmt =
                persistentChatEndpoint.PersistentChatServices.UserServices;

            PersistentChatUser persistentChatUser = userMgmt.EndGetUser(userMgmt.BeginGetUser(new Uri(persistentChatEndpoint.InnerEndpoint.OwnerUri), null, null));

            ChatRoomManagementServices chatRoomMgmt = persistentChatEndpoint.PersistentChatServices.ChatRoomManagementServices;

            try
            {
                ICollection <PersistentChatPrincipalSummary> members = new List <PersistentChatPrincipalSummary> {
                    persistentChatUser
                };
                chatRoomMgmt.EndAddUsersOrGroupsToRole(chatRoomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Member,
                                                                                                roomUri, members, null,
                                                                                                null));
            }
            catch (CommandFailedException cfe)
            {
                if (!cfe.ToString().Contains("These principals are already defined"))
                {
                    throw;
                }
            }
        }
        //-----------------------------------------------------------
        public static Uri RoomCreateUnderNonRootCategory(PersistentChatEndpoint persistentChatEndpoint, Uri parentCategoryUri, string chatRoomName)
        {
            Console.WriteLine(String.Format("Create new chat room [{0}] under [{1}]...", chatRoomName, parentCategoryUri));

            //   ChatRoomManagementServices chatRoomMgmt = persistentChatEndpoint.PersistentChatServices.ChatRoomManagementServices;
            ChatRoomManagementServices chatRoomMgmt = persistentChatEndpoint.PersistentChatServices.ChatRoomManagementServices;
            //   PersistentChatUserAdministrationServices userMgmt = persistentChatEndpoint.PersistentChatServices.UserAdministrationServices;



            ChatRoomSettings settings = new ChatRoomSettings(chatRoomName, parentCategoryUri);
            Uri roomUri = chatRoomMgmt.EndCreateChatRoom((chatRoomMgmt.BeginCreateChatRoom(settings, null, null)));

            // Add current user as member.
            PersistentChatUserServices userMgmt = persistentChatEndpoint.PersistentChatServices.UserServices;
            PersistentChatUser         user     = userMgmt.EndGetUser(userMgmt.BeginGetUser(new Uri(persistentChatEndpoint.InnerEndpoint.OwnerUri), null, null));

            ICollection <PersistentChatPrincipalSummary> members = new List <PersistentChatPrincipalSummary>();

            members.Add(user);
            chatRoomMgmt.EndAddUsersOrGroupsToRole(chatRoomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Presenter, roomUri, members, null, null));
            chatRoomMgmt.EndAddUsersOrGroupsToRole(chatRoomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Member, roomUri, members, null, null));

            //必须把自己加进去,创建和管理都是创建人的,其他的人设置会有问题


            Console.WriteLine("\t  Success  聊天室创建成果");
            return(roomUri);
        }
        public static PersistentChatUser GetUser(PersistentChatEndpoint persistentChatEndpoint, Uri uri)
        {
            Console.WriteLine(String.Format("GetUser --Uri------->eiail:", uri));
            PersistentChatUserServices ChatUserServices = persistentChatEndpoint.PersistentChatServices.UserServices;

            Console.WriteLine(String.Format("GetUser uri is get [{0}] ---Uri-----sss--->eiail:{1}", persistentChatEndpoint.InnerEndpoint.OwnerDisplayName, uri));
            PersistentChatUser pu = ChatUserServices.EndGetUser(
                ChatUserServices.BeginGetUser(uri, null, null));

            return(pu);
        }
Exemplo n.º 4
0
        private static void ChatRoomAddManagerAndMember(PersistentChatEndpoint persistentChatEndpoint, Uri chatroomUri, Uri userUri)
        {
            ChatRoomManagementServices chatroomMgmt = persistentChatEndpoint.PersistentChatServices.ChatRoomManagementServices;
            PersistentChatUserServices userMgmt     = persistentChatEndpoint.PersistentChatServices.UserServices;

            PersistentChatUser user = userMgmt.EndGetUser(userMgmt.BeginGetUser(userUri, null, null));
            List <PersistentChatPrincipalSummary> newUsers = new List <PersistentChatPrincipalSummary> {
                user
            };

            chatroomMgmt.EndAddUsersOrGroupsToRole((chatroomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Manager, chatroomUri, newUsers, null, null)));
            chatroomMgmt.EndAddUsersOrGroupsToRole((chatroomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Member, chatroomUri, newUsers, null, null)));
        }
Exemplo n.º 5
0
        private static void ChatRoomAddManagerAndMember(PersistentChatEndpoint persistentChatEndpoint, Uri chatroomUri, Uri userUri)
        {
            Log(String.Format("Adding manager+member [{0}] to Room [{1}]...", userUri, chatroomUri));

            ChatRoomManagementServices chatroomMgmt = persistentChatEndpoint.PersistentChatServices.ChatRoomManagementServices;
            PersistentChatUserServices userMgmt     = persistentChatEndpoint.PersistentChatServices.UserServices;

            PersistentChatUser user = userMgmt.EndGetUser(userMgmt.BeginGetUser(userUri, null, null));
            List <PersistentChatPrincipalSummary> newUsers = new List <PersistentChatPrincipalSummary> {
                user
            };

            chatroomMgmt.EndAddUsersOrGroupsToRole((chatroomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Manager, chatroomUri, newUsers, null, null)));
            chatroomMgmt.EndAddUsersOrGroupsToRole((chatroomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Member, chatroomUri, newUsers, null, null)));

            Log("\tSuccess");
        }
        public void ChatRoomAddManagerAndMember(PersistentChatEndpoint persistentChatEndpoint, Uri chatroomUri, Uri userUri)
        {
            Console.WriteLine(String.Format("Adding manager+member [{0}] to Room [{1}]...", userUri, chatroomUri));

            ChatRoomManagementServices chatroomMgmt = persistentChatEndpoint.PersistentChatServices.ChatRoomManagementServices;
            PersistentChatUserServices userMgmt     = persistentChatEndpoint.PersistentChatServices.UserServices;

            PersistentChatUser user = userMgmt.EndGetUser(userMgmt.BeginGetUser(userUri, null, null));
            List <PersistentChatPrincipalSummary> newUsers = new List <PersistentChatPrincipalSummary> {
                user
            };

            chatroomMgmt.EndAddUsersOrGroupsToRole((chatroomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Manager, chatroomUri, newUsers, null, null)));
            //    chatroomMgmt.EndAddUsersOrGroupsToRole((chatroomMgmt.BeginAddUsersOrGroupsToRole(ChatRoomRole.Member, chatroomUri, newUsers, null, null)));

            Console.WriteLine("\t {0} client {1} ChatRoomAddManagerAndMember  {2} Success", userName, chatroomUri, userUri);
        }
        public static PersistentChatUser GetUser(PersistentChatEndpoint persistentChatEndpoint, string lastName, string firstName, string email)
        {
            Console.WriteLine(String.Format("GetUser ---++++++++++++----vv-->eiail:{0}", email));
            PersistentChatUserServices ChatUserServices = persistentChatEndpoint.PersistentChatServices.UserServices;
            bool moreAvailable;
            PersistentChatPrincipalSummary ps = ChatUserServices.EndFindUsers(ChatUserServices.BeginFindUsers(lastName, firstName, email, null, null), out moreAvailable).FirstOrDefault();

            if (ps == null)
            {
                Console.WriteLine(String.Format("GetUser  do'nt get [{0}]...  PersistentChatPrincipalSummary is null eiail:{1}", persistentChatEndpoint.InnerEndpoint.OwnerDisplayName, email));
                //    Console.ReadLine();
                return(null);
            }
            Console.WriteLine(String.Format("GetUser uri is get [{0}] ---PersistentChatPrincipalSummary isn't null------>eiail:{1}", persistentChatEndpoint.InnerEndpoint.OwnerDisplayName, ps.Uri));
            PersistentChatUser pu = ChatUserServices.EndGetUser(
                ChatUserServices.BeginGetUser(ps.Uri, null, null));

            // ChatUserServices.BeginGetUser(ps.Uri, null, null));
            Console.ReadLine();
            Console.WriteLine(String.Format("GetUser uri is get [{0}] --88888888888----->eiail:{1}", persistentChatEndpoint.InnerEndpoint.OwnerDisplayName, ps.Uri));
            return(pu);
        }