예제 #1
0
            public void Stop()
            {
                currentOperation.Stop(
                    () =>
                {
                    // Wait for rooms to stop doing work
                    List <WaitHandle> waitHandles = new List <WaitHandle>();
                    foreach (SimulatedChatRoom room in chatRoomSessions)
                    {
                        waitHandles.Add(room.WaitForStopped);
                        room.Stop();
                    }
                    if (waitHandles.Count > 0)
                    {
                        WaitHandle.WaitAll(waitHandles.ToArray());
                    }
                },
                    () =>
                {
                    // Teardown
                    chatRoomSessions.Clear();
                    chatRooms.Clear();

                    if (persistentChatEndpoint != null)
                    {
                        SampleCommon.DisconnectPersistentChatServer(persistentChatEndpoint);
                        persistentChatEndpoint = null;
                    }
                    if (userEndpoint != null)
                    {
                        SampleCommon.DisconnectOfficeCommunicationServer(userEndpoint);
                        userEndpoint = null;
                    }
                });
            }
예제 #2
0
        public static void Main(string[] args)
        {
            //////////////////////////////////////////////////////////////////////////////////////////////////
            // Note: Assuming that category(ies) have been created and this user is a creator on some of them
            //////////////////////////////////////////////////////////////////////////////////////////////////

            try
            {
                // Connect to OCS
                UserEndpoint userEndpoint = SampleCommon.ConnectOfficeCommunicationServer(SampleCommon.UserSipUri,
                                                                                          SampleCommon.OcsServer,
                                                                                          SampleCommon.UsingSso,
                                                                                          SampleCommon.Username,
                                                                                          SampleCommon.Password);

                // Connect to Persistent Chat Server
                PersistentChatEndpoint persistentChatEndpoint = SampleCommon.ConnectPersistentChatServer(userEndpoint,
                                                                                                         SampleCommon.
                                                                                                         PersistentChatServerUri);

                SetupRooms(persistentChatEndpoint);

                GetRiamoLists(persistentChatEndpoint);

                // Disconnect from both Persistent Chat Server and OCS
                SampleCommon.DisconnectPersistentChatServer(persistentChatEndpoint);
                SampleCommon.DisconnectOfficeCommunicationServer(userEndpoint);
            }
            catch (InvalidOperationException invalidOperationException)
            {
                Console.Out.WriteLine("InvalidOperationException: " + invalidOperationException.Message);
            }
            catch (ArgumentNullException argumentNullException)
            {
                Console.Out.WriteLine("ArgumentNullException: " + argumentNullException.Message);
            }
            catch (ArgumentException argumentException)
            {
                Console.Out.WriteLine("ArgumentException: " + argumentException.Message);
            }
            catch (Microsoft.Rtc.Signaling.AuthenticationException authenticationException)
            {
                Console.Out.WriteLine("AuthenticationException: " + authenticationException.Message);
            }
            catch (Microsoft.Rtc.Signaling.FailureResponseException failureResponseException)
            {
                Console.Out.WriteLine("FailureResponseException: " + failureResponseException.Message);
            }
            catch (UriFormatException uriFormatException)
            {
                Console.Out.WriteLine("UriFormatException: " + uriFormatException.Message);
            }
            catch (Exception exception)
            {
                Console.Out.WriteLine("Exception: " + exception.Message);
            }
        }
예제 #3
0
        /// <summary>
        /// Create the category and chat rooms if they are missing, or simply find their Uris if they
        /// exist already (presumably from a previous run of this sample code).
        /// </summary>
        /// <param name="clients"></param>
        /// <returns></returns>
        private static List <Uri> SetupChatRooms(IEnumerable <SimulatedClient> clients)
        {
            List <Uri> chatRooms = new List <Uri>();

            try
            {
                UserEndpoint userEndpoint = SampleCommon.ConnectOfficeCommunicationServer(SampleCommon.UserSipUri,
                                                                                          SampleCommon.OcsServer,
                                                                                          SampleCommon.UsingSso,
                                                                                          SampleCommon.Username,
                                                                                          SampleCommon.Password);
                PersistentChatEndpoint persistentChatEndpoint = SampleCommon.ConnectPersistentChatServer(userEndpoint,
                                                                                                         SampleCommon.
                                                                                                         PersistentChatServerUri);
                // Get a category
                Uri categoryUri = SampleCommon.GetCategoryUri(persistentChatEndpoint);

                foreach (string roomName in SampleCommon.LoadTestChatRoomNames)
                {
                    Uri roomUri = SampleCommon.RoomCreateUnderNonRootCategory(persistentChatEndpoint, categoryUri,
                                                                              roomName + "_" + TestRunUniqueId);
                    chatRooms.Add(roomUri);

                    // Setup all the test users as Managers and Members in this chat room
                    // thus allowing these users to join the chat rooms during this sample's execution.
                    foreach (SimulatedClient client in clients)
                    {
                        ChatRoomAddManagerAndMember(persistentChatEndpoint, roomUri, client.UserUri);
                    }
                }

                SampleCommon.DisconnectPersistentChatServer(persistentChatEndpoint);
                SampleCommon.DisconnectOfficeCommunicationServer(userEndpoint);
            }
            catch (InvalidOperationException invalidOperationException)
            {
                Console.Out.WriteLine("InvalidOperationException: " + invalidOperationException.Message);
            }
            catch (ArgumentNullException argumentNullException)
            {
                Console.Out.WriteLine("ArgumentNullException: " + argumentNullException.Message);
            }
            catch (ArgumentException argumentException)
            {
                Console.Out.WriteLine("ArgumentException: " + argumentException.Message);
            }
            catch (Microsoft.Rtc.Signaling.AuthenticationException authenticationException)
            {
                Console.Out.WriteLine("AuthenticationException: " + authenticationException.Message);
            }
            catch (Microsoft.Rtc.Signaling.FailureResponseException failureResponseException)
            {
                Console.Out.WriteLine("FailureResponseException: " + failureResponseException.Message);
            }
            catch (UriFormatException uriFormatException)
            {
                Console.Out.WriteLine("UriFormatException: " + uriFormatException.Message);
            }
            catch (Exception exception)
            {
                Console.Out.WriteLine("Exception: " + exception.Message);
            }
            return(chatRooms);
        }
예제 #4
0
        public static void Main(string[] args)
        {
            //////////////////////////////////////////////////////////////////////////////////////////////////
            // Note: Assuming that category(ies) have been created and this user is a creator on some of them
            //////////////////////////////////////////////////////////////////////////////////////////////////

            //// Appending a GUID here so you can run this sample multiple times without attempting to create
            //// the same channel twice.
            string chatRoomName = "SampleChat_TestRoom" + TestRunUniqueId;

            try
            {
                ChatRoomSession roomSession;

                // Connect to Lync Server
                UserEndpoint userEndpoint = SampleCommon.ConnectOfficeCommunicationServer(SampleCommon.UserSipUri,
                                                                                          SampleCommon.OcsServer,
                                                                                          SampleCommon.UsingSso,
                                                                                          SampleCommon.Username,
                                                                                          SampleCommon.Password);

                // Connect to Persistent Chat Server
                PersistentChatEndpoint persistentChatEndpoint = SampleCommon.ConnectPersistentChatServer(userEndpoint, SampleCommon.PersistentChatServerUri);

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

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

                // Change this to try out different ways to join the same channel
                string answer = GetRoomAnswer();

                bool joinByUri = answer.Equals("U");
                if (joinByUri)
                {
                    // OPTION 1: Join by using the result of the Create operation:
                    roomSession = SampleCommon.RoomJoinExisting(persistentChatEndpoint, roomUri);
                }
                else
                {
                    // OPTION 2: Join by searching for the room by name:
                    ChatRoomSnapshot roomSnapshot = SampleCommon.RoomSearchExisting(persistentChatEndpoint, chatRoomName);
                    roomSession = SampleCommon.RoomJoinExisting(persistentChatEndpoint, roomSnapshot);
                }

                // Chat in the chat room
                RoomChat(roomSession);

                // Get the chat history from the room
                RoomChatHistory(roomSession);

                // Search the chat history for a room
                RoomSearchChatHistory(persistentChatEndpoint, roomSession, "story body");

                // Leave room
                RoomLeave(roomSession);

                // Disconnect from Persistent Chat and from OCS
                SampleCommon.DisconnectPersistentChatServer(persistentChatEndpoint);
                SampleCommon.DisconnectOfficeCommunicationServer(userEndpoint);
            }
            catch (InvalidOperationException invalidOperationException)
            {
                Console.Out.WriteLine("InvalidOperationException: " + invalidOperationException.Message);
            }
            catch (ArgumentNullException argumentNullException)
            {
                Console.Out.WriteLine("ArgumentNullException: " + argumentNullException.Message);
            }
            catch (ArgumentException argumentException)
            {
                Console.Out.WriteLine("ArgumentException: " + argumentException.Message);
            }
            catch (Microsoft.Rtc.Signaling.AuthenticationException authenticationException)
            {
                Console.Out.WriteLine("AuthenticationException: " + authenticationException.Message);
            }
            catch (Microsoft.Rtc.Signaling.FailureResponseException failureResponseException)
            {
                Console.Out.WriteLine("FailureResponseException: " + failureResponseException.Message);
            }
            catch (UriFormatException uriFormatException)
            {
                Console.Out.WriteLine("UriFormatException: " + uriFormatException.Message);
            }
            catch (Exception exception)
            {
                Console.Out.WriteLine("Exception: " + exception.Message);
            }
        }