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); } }
public static void startSampleChat() { string chatRoomName = "A5 ngwei---1" + TestRunUniqueId; try { ChatRoomSession roomSession; // Connect to Lync Server UserEndpoint userEndpoint = SampleCommon.ConnectLyncServer(SampleCommon.UserSipUri, SampleCommon.LyncServer, 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"); SampleLoadTest.roomUri = roomUri; // SampleLoadTest.getClient(); // SampleLoadTest.stopClient(); Console.Write(@" roomSession-------- leave "); Console.ReadLine(); // Leave room RoomLeave(roomSession); Console.Write(@" DisconnectPersistentChatServer leave "); Console.ReadLine(); // Disconnect from Persistent Chat and from Lync Server SampleCommon.DisconnectPersistentChatServer(persistentChatEndpoint); SampleCommon.DisconnectLyncServer(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); } }
/// <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); }
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); // Get a category Uri catUri = SampleCommon.GetCategoryUri(persistentChatEndpoint); // create 10 chat rooms IList <ChatRoomHelper> chatRooms = new List <ChatRoomHelper>(); for (int i = 0; i < 10; i++) { // Create a new chat room string chatRoomName; if (i < 5) { chatRoomName = "SampleSearch_TestRoom" + TestRunUniqueId; } else { chatRoomName = "Sample_TestRoom" + TestRunUniqueId; } chatRoomName += i; Uri chatRoomUri = SampleCommon.RoomCreateUnderNonRootCategory(persistentChatEndpoint, catUri, chatRoomName); chatRooms.Add(new ChatRoomHelper(chatRoomName, chatRoomUri)); } // Find chat rooms by name int randIndex = Random.Next(10); BrowseChatRoomByName(persistentChatEndpoint, chatRooms[randIndex].ChatRoomName); // Find chat rooms under a category BrowseChatRoomByCategory(persistentChatEndpoint, catUri); // Find chat rooms by criteria BrowseChatRoomsByCriteria(persistentChatEndpoint, "Sample_TestRoom"); // Find chat rooms by filter conditions: // Search Criteria: Name has "Sample" in it, UserSipUri is a member of the room, The room is Scoped and of type // Normal, and has invitations settings set to Inherit and we want only 100 results // All search criteria that we don't want to search under is passed as null BrowseChatRoomsByFilterCriteria(persistentChatEndpoint, "Sample", false, SampleCommon.UserSipUri, null, null, null, false, ChatRoomPrivacy.Closed, ChatRoomBehavior.Normal, null, true, 100); } 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); } }
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); } }
/// <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.ConnectLyncServer(SampleCommon.UserSipUri, SampleCommon.LyncServer, SampleCommon.UsingSso, SampleCommon.Username, SampleCommon.Password); PersistentChatEndpoint persistentChatEndpoint = SampleCommon.ConnectPersistentChatServer(userEndpoint, SampleCommon. PersistentChatServerUri); Console.WriteLine("Press any key to start the test, then press any key later to longin the test..."); Console.ReadKey(); foreach (string roomName in SampleCommon.LoadTestChatRoomNames) { 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.DisconnectLyncServer(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); }