private void EndPlatformStartup(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { collabPlatform.EndStartup(ar); } catch (OperationFailureException opFailEx) { log(opFailEx.Message); throw; } catch (ConnectionFailureException connFailEx) { log(connFailEx.Message); throw; } catch (RealTimeException realTimeEx) { // RealTimeException may be thrown as a result of any UCMA operation. log(realTimeEx.Message); throw; } finally { // Again, just for sync. reasons. _platformStartupCompleted.Set(); } }
// Callback for CollaborationPlatform's BeginStartup(). static void EndPlatformStartup(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { // The CollaborationPlatform should now be started. collabPlatform.EndStartup(ar); Console.WriteLine("Collaboration platform associated with the provisioned application has been started"); } catch (ProvisioningFailureException pfEx) { Console.WriteLine("ProvisioningFailure Exception: " + pfEx.ToString()); Console.WriteLine("The FailureReason for the ProvisioningFailure Exception: " + pfEx.FailureReason.ToString()); } catch (OperationFailureException opFailEx) { Console.WriteLine("OperationFailure Exception: " + opFailEx.ToString()); } catch (ConnectionFailureException connFailEx) { Console.WriteLine("ConnectionFailure Exception: " + connFailEx.ToString()); } catch (RealTimeException realTimeEx) { Console.WriteLine("RealTimeException : " + realTimeEx.ToString()); } }
public void Run() { // Create and establish the endpoint, using the credentials of the user the application will be acting as. _helper = new UCMASampleHelper(); _userEndpoint = _helper.CreateEstablishedUserEndpoint("VoiceXML Sample User" /*endpointFriendlyName*/); _userEndpoint.RegisterForIncomingCall <AudioVideoCall>(inboundAVCall_CallReceived); // Pause the main thread until a call is received and then accepted. _waitForCallReceived.WaitOne(); _waitForCallAccepted.WaitOne(); InitializeVoiceXmlBrowser(); _voiceXmlBrowser.SetAudioVideoCall(_audioVideoCall); Uri startPageURI = new Uri(startPageURL); Console.WriteLine("Browser state: " + _voiceXmlBrowser.State.ToString()); _voiceXmlBrowser.RunAsync(startPageURI, null); _waitForSessionCompleted.WaitOne(); _collabPlatform = _conversation.Endpoint.Platform; // Terminate the call. _audioVideoCall.BeginTerminate(CallTerminateCB, _audioVideoCall); _waitForPlatformShutdownCompleted.WaitOne(); // Pause the console to allow the user to view logs. Console.WriteLine("Press any key to end the sample."); Console.ReadKey(); }
private async Task EstablishCollaborationPlatform() { string userAgent = "IFTTT/Email Lync Instant Message Sender"; var platformSettings = new ClientPlatformSettings(userAgent, Microsoft.Rtc.Signaling.SipTransportType.Tls); try { Console.WriteLine("Trying to start collab platform"); _collabPlatform = new CollaborationPlatform(platformSettings); _collabPlatform.ProvisioningFailed += _collabPlatform_ProvisioningFailed; _collabPlatform.AllowedAuthenticationProtocol = Microsoft.Rtc.Signaling.SipAuthenticationProtocols.Ntlm; await _collabPlatform.StartupAsync(); _endpointStarted = true; Console.WriteLine("Collab Platform Started."); } catch (Exception ex) { Console.WriteLine("Error starting collab platform"); Console.WriteLine(ex.ToString()); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.ToString()); } else { Console.WriteLine("Inner exception is empty"); } } }
public void Start(List <Uri> chatRoomsToJoin) { Console.WriteLine("正在登陆用户"); Console.ReadKey(); try { chatRooms = chatRoomsToJoin; // Connect to Lync Server ClientPlatformSettings platformSettings = new ClientPlatformSettings("PersistentChat.Test", SipTransportType.Tls); CollaborationPlatform collabPlatform = new CollaborationPlatform(platformSettings); collabPlatform.EndStartup(collabPlatform.BeginStartup(null, null)); UserEndpointSettings userEndpointSettings = new UserEndpointSettings(UserUri.AbsoluteUri, SampleCommon.LyncServer); userEndpointSettings.Credential = new NetworkCredential(UserName, Password); userEndpoint = new UserEndpoint(collabPlatform, userEndpointSettings); Console.WriteLine("正在登陆用户----------->"); // Login to Lync Server currentOperation.Begin("Connect to Lync Server", () => userEndpoint.BeginEstablish(ar => LyncServerBeginEstablishFinished(ar), null)); } catch (Exception e) { Console.WriteLine("正在登陆用户"); } }
private void ShutdownCollaborationPlatform(AsyncTask task, object state) { CollaborationPlatform platform = m_platform; if (platform == null) { task.Complete(null); return; } task.DoOneStep( delegate() { m_platform.BeginShutdown( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_platform.EndShutdown(ar); this.Logger.Log(Logger.LogLevel.Info, "Platform shutdown completed."); }); }, null); }); }
public static Task ChangeCertificateAsync(this CollaborationPlatform platform, string certificateIssuerName, byte[] certificateSerialNumber) { return(Task.Factory.FromAsync(platform.BeginChangeCertificate, platform.EndChangeCertificate, certificateIssuerName, certificateSerialNumber, null)); }
/// <summary> /// Sets up the OCS objects using the credentials provided /// </summary> /// <remarks> /// In this sample this is invoked when the user presses the "Apply Server Settings" button /// </remarks> /// <param name="applicationUri">SIP Uri of the OCS account</param> /// <param name="serverName">SIP server URI</param> /// <param name="serverPort">Port (usually 443)</param> /// <param name="credential">Credentials for establishing the user endpoint</param> private void InitializeMCSConnection(string applicationUri, string serverName, int serverPort, NetworkCredential credential) { //Initialize new client platform. //Note that this sample only supports TLS, and additionally that it uses ClientPlatform rather than ServerPlatform. //In a production application, ServerPlatform should be used; ClientPlatform is preferred here to demonstrate the platform without //requiring application provisioning. This is out of the scope of this sample, however. ClientPlatformSettings clientPlatformSettings; clientPlatformSettings = new ClientPlatformSettings("VoiceXMLTestApp", SipTransportType.Tls); collaborationPlatform = new CollaborationPlatform(clientPlatformSettings); collaborationPlatform.EndStartup(collaborationPlatform.BeginStartup(null, null)); //Create a new UserEndpoint based on the information provided through the UI. //As with Server/Client platform above, in production, this should be replaced with provisioned ApplicationEndpoint in most circumstances. UserEndpointSettings endpointSettings; endpointSettings = new UserEndpointSettings(applicationUri, serverName, serverPort); endpoint = new UserEndpoint(collaborationPlatform, endpointSettings); endpoint.Credential = credential; //Bind the event handler to handle incoming calls. Use of the strongly-typed AVCall dictates that calls not matching this type will not be raised. endpoint.RegisterForIncomingCall <AudioVideoCall>(AudioVideoCallReceived); endpoint.EndEstablish(endpoint.BeginEstablish(null, endpoint)); }
/// <summary> /// Creates the P2PEndpoint for sending the Notify. A P2P endpoint enjoys /// auto-provisioning of the necessary application endpoint settings /// if it is obtained from an established ApplicationEndpoint created with /// ProvisionedApplicationPlatformSettings. /// </summary> void CreateP2PEndpoint() { Console.WriteLine("Creating P2P Endpoint...for {0}", _appID); try { if (!string.IsNullOrEmpty(_appID)) { Console.WriteLine("Creating CollaborationPlatform for the provisioned application with " + "ID \'{0}\' using ProvisionedApplicationPlatformSettings.", _appID); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("UCMASampleApp", _appID); _collabPlatform = new CollaborationPlatform(settings); // Receive applicationEndpoint settings via auto-provisioning _collabPlatform.RegisterForApplicationEndpointSettings(ApplicationEndpointSettingsDiscovered); _collabPlatform.EndStartup(_collabPlatform.BeginStartup(null, null)); Console.WriteLine("platform started."); } else { Console.WriteLine("Error: Application ID not provided."); } } catch (Exception iOpEx) { Console.WriteLine(iOpEx.ToString()); } }
/// <summary> /// Retrieves the application configuration and begins running the /// sample. /// </summary> void Run() { _appID = null; try { // Attempt to retrieve the application ID of the provisioned // application from the config file. _appID = System.Configuration.ConfigurationManager.AppSettings["ApplicationID"]; if (string.IsNullOrEmpty(_appID)) { // The application ID wasn't retrieved from the config file // so prompt for the application ID for the application that // has been provisioned. string prompt = "Please enter the unique ID of the application that is provisioned in " + "the topology => "; _appID = UCMASampleHelper.PromptUser(prompt, null); } if (!string.IsNullOrEmpty(_appID)) { Console.WriteLine("Creating CollaborationPlatform for the provisioned application with " + "ID \'{0}\' using ProvisionedApplicationPlatformSettings.", _appID); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("UCMASampleApp", _appID); _collabPlatform = new CollaborationPlatform(settings); // Wire up a handler for the // ApplicationEndpointOwnerDiscovered event. _collabPlatform.RegisterForApplicationEndpointSettings( this.Platform_ApplicationEndpointOwnerDiscovered); // Initialize and startup the platform. _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform); } else { Console.WriteLine("No application ID was specified by the user."); } UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit."); } catch (InvalidOperationException iOpEx) { // Invalid Operation Exception may be thrown if the data // provided to the BeginXXX methods was // invalid/malformed. // TODO (Left to the reader): Write actual handling code for the // occurrence. Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString()); } finally { // Terminate the platform which would in turn terminate any // endpoints. Console.WriteLine("Shutting down the platform."); ShutdownPlatform(); } }
private void EndPlatformShutdown(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; //Shutdown actions will not throw. collabPlatform.EndShutdown(ar); Console.WriteLine("The platform is now shutdown."); //Again, just to sync the completion of the code and the platform teardown. _waitForShutdownEventCompleted.Set(); }
public UserEndpoint CreateUserEndpoint(UserEndpointSettings userEndpointSettings) { if (_collabPlatform == null) { // Initalize and startup the platform. ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType); _collabPlatform = new CollaborationPlatform(clientPlatformSettings); } _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings); return(_userEndpoint); }
public static void DisconnectOfficeCommunicationServer(UserEndpoint userEndpoint) { Console.WriteLine("Disconnecting from OCS..."); userEndpoint.EndTerminate(userEndpoint.BeginTerminate(null, null)); CollaborationPlatform platform = userEndpoint.Platform; platform.EndShutdown(platform.BeginShutdown(null, null)); Console.WriteLine("\tSuccess"); }
// Callback for CollaborationPlatform's BeginStartup(). private void EndPlatformStartup(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { // The CollaborationPlatform should now be started. collabPlatform.EndStartup(ar); Console.WriteLine("Collaboration platform associated with the provisioned application with " + "ID {0} has been started", _appID); } catch (ProvisioningFailureException pfEx) { // ProvisioningFailureException may be thrown during // EndStartup() for many reasons such as inaccessible // configuration data, unable to find a matching application, // and invalid configuration data. The FailureReason property // exposes these issues via a value of the // ProvisioningFailureReason enumerated type, which can have // values of ConfigurationDataInaccessible, ApplicationNotFound, // and InvalidConfiguration. // TODO (Left to the reader): Write actual handling code for the // occurrence. Console.WriteLine("ProvisioningFailure Exception: " + pfEx.ToString()); Console.WriteLine("The FailureReason for the ProvisioningFailure Exception: " + pfEx.FailureReason.ToString()); } catch (OperationFailureException opFailEx) { // OperationFailureException will be thrown when the platform // cannot establish, usually due to invalid data. // TODO (Left to the reader): Write actual handling code for the // occurrence. Console.WriteLine("OperationFailure Exception: " + opFailEx.ToString()); } catch (ConnectionFailureException connFailEx) { // ConnectionFailureException will be thrown when the platform // cannot connect. // TODO (Left to the reader): Write actual handling code for the // occurrence. Console.WriteLine("ConnectionFailure Exception: " + connFailEx.ToString()); } catch (RealTimeException realTimeEx) { // RealTimeException may be thrown as a result of any UCMA // operation. // TODO (Left to the reader): Write actual handling code for the // occurrence. Console.WriteLine("RealTimeException : " + realTimeEx.ToString()); } }
// Method to create an endpoint given a UserEndpointSettings object. // This method returns a UserEndpoint object so that you can wire up Endpoint-specific event handlers. // If you do not want to get endpoint specific event information at the time the endpoint is established, you may // want to call the CreateEstablishedUserEndpoint method directly. Otherwise, you may call ReadUserSettings // followed by CreateUserEndpoint, followed by EstablishUserEndpoint methods. public UserEndpoint CreateUserEndpoint(UserEndpointSettings userEndpointSettings) { // Reuse platform instance so that all endpoints share the same platform. if (_collabPlatform == null) { // Initialize and start the platform. ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType); _collabPlatform = new CollaborationPlatform(clientPlatformSettings); } _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings); return(_userEndpoint); }
private void EndPlatformShutdown(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { //Shutdown actions will not throw. collabPlatform.EndShutdown(ar); NonBlockingConsole.WriteLine("The platform is now shut down."); } finally { _platformShutdownCompletedEvent.Set(); } }
// Callback referenced in the BeginShutdown method on the platform. private void PlatformShutdownCB(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { // Shutdown actions will not throw. collabPlatform.EndShutdown(ar); Console.WriteLine("The platform is now shut down."); } finally { _waitForPlatformShutdownCompleted.Set(); } }
private void CreateAndStartServerPlatform() { var certToUse = GetLocalCertificate(_certificateFriendlyName); ServerPlatformSettings serverPlatformSettings = new ServerPlatformSettings(_applicationName, _applicationHostFQDN, _applicationPort, _applicationGruu, certToUse); _serverCollabPlatform = new CollaborationPlatform(serverPlatformSettings); // Startup the platform. _serverCollabPlatform.BeginStartup(EndPlatformStartup, _serverCollabPlatform); // Sync; wait for the startup to complete. _platformStartupCompleted.WaitOne(); Console.WriteLine("Platform started..."); }
public async Task Start() { try { Console.WriteLine("Starting Collaboration Platform"); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings(_appUserAgent, _appID); _collabPlatform = new CollaborationPlatform(settings); _collabPlatform.RegisterForApplicationEndpointSettings(OnNewApplicationEndpointDiscovered); await _collabPlatform.StartupAsync(); Console.WriteLine("Platform Started"); } catch (Exception ex) { Console.WriteLine("Error establishing collaboration platform: {0}", ex.ToString()); } }
void Run() { _AppID = System.Configuration.ConfigurationManager.AppSettings["ApplicationID"]; ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("My UCMA Application", _AppID); _CollabPlatform = new CollaborationPlatform(settings); _CollabPlatform.RegisterForApplicationEndpointSettings(Platform_ApplicationEndpointOwnerDiscovered); Console.WriteLine("Starting collaboration platform"); _CollabPlatform.BeginStartup(PlatformStartupComplete, _CollabPlatform); //PauseBeforeContinuing("Press enter to shutdown and exit"); Console.WriteLine("Shutting down the platform."); //ShutdownPlatform(); }
public void StartupPlatform() { try { ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings(LumtGlobals.ApplicationUserAgent, LumtGlobals.TrustedApplicationID); collabPlatform = new CollaborationPlatform(settings); Log.WriteLogEntry("INFO", String.Format("Starting {0} platform...", LumtGlobals.ApplicationShortName)); collabPlatform.EndStartup(collabPlatform.BeginStartup(null, null)); Log.WriteLogEntry("INFO", String.Format("{0} platform started.", LumtGlobals.ApplicationShortName)); } catch (Exception ex) { Log.WriteLogEntry("ERROR", String.Format("{0} platform NOT started: {1}. Inner Exception: {2}", LumtGlobals.ApplicationShortName, ex.Message, (ex.InnerException == null ? "N/A" : ex.InnerException.Message)), String.Format("{0} platform NOT started.", LumtGlobals.ApplicationShortName)); Program.CloseApplicationOnError(); } }
// Method to shutdown the CollaborationPlatform. static void ShutdownPlatform() { _collabPlatform.BeginShutdown(ar => { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { collabPlatform.EndShutdown(ar); Console.WriteLine("The platform is now shut down."); } catch (RealTimeException realTimeEx) { Console.WriteLine("RealTimeException: " + realTimeEx.ToString()); } }, _collabPlatform); }
// Callback for CollaborationPlatform's BeginShutdown(). void EndPlatformShutdown(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { collabPlatform.EndShutdown(ar); Console.WriteLine("The platform is now shut down."); } catch (RealTimeException realTimeEx) { // RealTimeException may be thrown as a result of any // UCMA operation. // TODO (Left to the reader): Error handling code. Console.WriteLine("RealTimeException : " + realTimeEx.ToString()); } }
private void EndPlatformStartup(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { collabPlatform.EndStartup(ar); Console.WriteLine("The platform is now started."); } catch (ConnectionFailureException connFailEx) { //ConnectionFailureException will be thrown when the platform cannot connect. Console.WriteLine(connFailEx.ToString()); } //Again, just for sync. reasons. _autoResetEvent.Set(); }
public void Start() { // Get the application ID from App.config. string applicationUserAgent = "maximillian"; string applicationId = ConfigurationManager.AppSettings["applicationId"]; // Create a settings object. ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings(applicationUserAgent, applicationId); // Create a new collaboration platform with the settings. _collaborationPlatform = new CollaborationPlatform(settings); _collaborationPlatform.RegisterForApplicationEndpointSettings(OnApplicationEndpointSettingsDiscovered); _logger.Log("Starting collaboration platform..."); // Start the platform as an asynchronous operation. _collaborationPlatform.BeginStartup(OnPlatformStartupCompleted, null); }
public static void Main(string[] args) { try { string appId = ConfigurationManager.AppSettings["ApplicationID"]; Console.WriteLine("Creating CollaborationPlatform for the provisioned application with " + "ID \'{0}\' using ProvisionedApplicationPlatformSettings.", appId); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("UCMASampleApp", appId); settings.DefaultAudioVideoProviderEnabled = true; _collabPlatform = new CollaborationPlatform(settings); _collabPlatform.InstantMessagingSettings.SupportedFormats = InstantMessagingFormat.All; // Wire up a handler for the // ApplicationEndpointOwnerDiscovered event. _collabPlatform.RegisterForApplicationEndpointSettings( Platform_ApplicationEndpointOwnerDiscovered); // Initalize and startup the platform. _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform); Console.WriteLine("Please hit Esc key to end the sample."); ConsoleKeyInfo info = Console.ReadKey(); while (info.Key != ConsoleKey.Escape) { info = Console.ReadKey(); } } catch (InvalidOperationException iOpEx) { Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString()); } finally { Console.WriteLine("Shutting down the platform."); ShutdownPlatform(); } }
protected override async void OnStart(string[] args) { if (!Directory.Exists(Path.Combine(ZMachineSettings.AppDataFolder, "Saves"))) { Directory.CreateDirectory(Path.Combine(ZMachineSettings.AppDataFolder, "Saves")); } if (!Directory.Exists(Path.Combine(ZMachineSettings.AppDataFolder, "Games"))) { Log.Warn("No Z-Machine games included"); Directory.CreateDirectory(Path.Combine(ZMachineSettings.AppDataFolder, "Games")); } else { if (!Directory.GetFiles(Path.Combine(ZMachineSettings.AppDataFolder, "Games")).Any()) { Log.Warn("No Z-Machine games included"); } } var clientPlatformSettings = new ClientPlatformSettings("LyncZMachine", SipTransportType.Tls); _collabPlatform = new CollaborationPlatform(clientPlatformSettings); await _collabPlatform.StartupAsync(); _settings = new UserEndpointSettings( ZMachineSettings.Settings.Sip, ZMachineSettings.Settings.LyncServer //ConfigurationManager.AppSettings["sip"], //ConfigurationManager.AppSettings["LyncServer"] ) { Credential = new NetworkCredential( ZMachineSettings.Settings.Username, ZMachineSettings.Settings.Password, ZMachineSettings.Settings.Domain //ConfigurationManager.AppSettings["username"], //ConfigurationManager.AppSettings["pw"], //ConfigurationManager.AppSettings["domain"] ), AutomaticPresencePublicationEnabled = true }; _settings.Presence.UserPresenceState = PresenceState.UserAvailable; _endpoint = new UserEndpoint(_collabPlatform, _settings); await _endpoint.EstablishAsync(); _endpoint.RegisterForIncomingCall<InstantMessagingCall>(GameStarted); _webServer = WebApp.Start<Startup>(string.Format("http://+:{0}/ZMachine", ZMachineSettings.Settings.Port)); }
/// <summary> /// Callback method for platform shutdown method /// </summary> /// <param name="result">Async result</param> private void PlatformShutdownCompleted(IAsyncResult result) { CollaborationPlatform collabPlatform = result.AsyncState as CollaborationPlatform; try { //Shutdown actions will not throw. collabPlatform.EndShutdown(result); } finally { Helper.Logger.Info("The platform is now shutdown."); var allDone = m_allDone; if (allDone != null) { allDone.Set(); } } }
/// <summary> /// Callback from <code>BeginShutdown</code> method on platform. /// </summary> /// <param name="result"> /// Status of the platform shutdown operation. /// </param> private void PlatformShutdownCompleted(IAsyncResult result) { // Extract the platform that was passed in as the state argument to // the BeginShutdown() method. CollaborationPlatform platform = result.AsyncState as CollaborationPlatform; if (platform == null) { UCMASampleHelper.WriteErrorLine( "CollaborationPlatform not passed into BeginShutdown() method."); UCMASampleHelper.FinishSample(); return; } // Determine whether the shutdown operation completed // successfully. platform.EndShutdown(result); UCMASampleHelper.WriteLine("The platform is now shut down."); }
public void Start() { // Get the trusted application settings from App.config string appUserAgent = "MyUCMAApp"; string applicationId = ConfigurationManager.AppSettings["applicationId"]; string applicationName = ConfigurationManager.AppSettings["applicationName"]; string localhost = System.Net.Dns.GetHostEntry("localhost").HostName; int listeningPort = int.Parse(ConfigurationManager.AppSettings["listeningPort"]); string gruu = ConfigurationManager.AppSettings["gruu"]; // Create a settings object that will hold all the previous information var settings = new ProvisionedApplicationPlatformSettings(appUserAgent, applicationId); //ServerPlatformSettings settings = new ServerPlatformSettings(applicationName, localhost, listeningPort, gruu, CertificateHelper.GetLocalCertificate()); // Create a new collaboration platform with the settings _collaborationPlatform = new CollaborationPlatform(settings); // Start the platform as an asynchronous operation _collaborationPlatform.BeginStartup(OnPlatformStartupCompleted, null); }
public void Start() { // Get the trusted application settings from App.config string appUserAgent = "MyUCMAApp"; string applicationId = "urn:application:myucmaapp"; string localhost = System.Net.Dns.GetHostEntry("localhost").HostName; int listeningPort = int.Parse("10600"); _recipientSipUri = "sip:[email protected]"; // Create a settings object that will hold all the previous information var settings = new ProvisionedApplicationPlatformSettings(appUserAgent, applicationId); //ServerPlatformSettings settings = new ServerPlatformSettings(applicationName, localhost, listeningPort, gruu, CertificateHelper.GetLocalCertificate()); // Create a new collaboration platform with the settings _collaborationPlatform = new CollaborationPlatform(settings); // Start the platform as an asynchronous operation _collaborationPlatform.BeginStartup(OnPlatformStartupCompleted, null); }
private static ApplicationEndpoint CreateEndPoint(ServerPlatformSettings settings) { CollaborationPlatform collaborationPlatform = new CollaborationPlatform(settings); collaborationPlatform.EndStartup(collaborationPlatform.BeginStartup(null, null)); ApplicationEndpoint result; try { ApplicationEndpoint applicationEndpoint = new ApplicationEndpoint(collaborationPlatform, new ApplicationEndpointSettings(BaseUMconnectivityTester.SipPlatformConnectionManager.OwnerUri)); applicationEndpoint.EndEstablish(applicationEndpoint.BeginEstablish(null, null)); result = applicationEndpoint; } catch (Exception) { collaborationPlatform.EndShutdown(collaborationPlatform.BeginShutdown(null, null)); throw; } return(result); }
private void EndPlatformShutdown(IAsyncResult ar) { CollaborationPlatform collabPlatform = ar.AsyncState as CollaborationPlatform; try { //xueming add //_userEndpoint.EndEstablish(); collabPlatform.EndShutdown(ar); //_collabPlatform.EndShutdown(ar); _userEndpoint = null; _collabPlatform = null; _isPlatformStarted = false; } finally { _platformShutdownCompletedEvent.Set(); } }
public void Start(List <Uri> chatRoomsToJoin) { chatRooms = chatRoomsToJoin; Log(string.Format("Start Client: chatRooms.Count={0}", chatRooms.Count)); currentOperation.Reset(); // Connect to OCS ClientPlatformSettings platformSettings = new ClientPlatformSettings("PersistentChat.Test", SipTransportType.Tls); CollaborationPlatform collabPlatform = new CollaborationPlatform(platformSettings); collabPlatform.EndStartup(collabPlatform.BeginStartup(null, null)); UserEndpointSettings userEndpointSettings = new UserEndpointSettings(UserUri.AbsoluteUri, SampleCommon.OcsServer); userEndpointSettings.Credential = new NetworkCredential(UserName, Password); userEndpoint = new UserEndpoint(collabPlatform, userEndpointSettings); // Login to OCS currentOperation.Begin("Connect to OCS", () => userEndpoint.BeginEstablish(OcsBeginEstablishFinished, null)); }
/// <summary> /// Helper method to clean up every thing and exit. /// </summary> private void Cleanup() { CollaborationPlatform platform = m_collabPlatform; bool allDone = true; try { if (platform != null) { platform.BeginShutdown(this.PlatformShutdownCompleted, platform); allDone = false; } } finally { var allDoneEventHandle = m_allDone; if (allDone && allDoneEventHandle != null) { allDoneEventHandle.Set(); } } }
// Method to create an endpoint given a UserEndpointSettings object. // This method returns a UserEndpoint object so that you can wire up Endpoint-specific event handlers. // If you do not want to get endpoint specific event information at the time the endpoint is established, you may // want to call the CreateEstablishedUserEndpoint method directly. Otherwise, you may call ReadUserSettings // followed by CreateUserEndpoint, followed by EstablishUserEndpoint methods. public UserEndpoint CreateUserEndpoint(UserEndpointSettings userEndpointSettings) { // Reuse platform instance so that all endpoints share the same platform. if (_collabPlatform == null) { // Initialize and start the platform. ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType); _collabPlatform = new CollaborationPlatform(clientPlatformSettings); } _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings); return _userEndpoint; }
private async void btnTest_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; var clientPlatformSettings = new ClientPlatformSettings("LyncZMachine", SipTransportType.Tls); var collabPlatform = new CollaborationPlatform(clientPlatformSettings); await collabPlatform.StartupAsync(); var settings = new UserEndpointSettings(txtSip.Text, txtServer.Text) { Credential = new NetworkCredential(txtUsername.Text, txtPassword.Text, txtDomain.Text), AutomaticPresencePublicationEnabled = true }; var endpoint = new UserEndpoint(collabPlatform, settings); await endpoint.EstablishAsync(); btnSave.Enabled = true; MessageBox.Show("Connected successfully to " + txtServer.Text + " as " + txtSip.Text); try { await endpoint.TerminateAsync(); await collabPlatform.ShutdownAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "An Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message, "An Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); btnSave.Enabled = false; } finally { Cursor = Cursors.Default; } }