CollaborationPlatform.BeginStartup Method
Initializes the platform object.
Namespace: Microsoft.Rtc.Collaboration
Assembly: Microsoft.Rtc.Collaboration (in Microsoft.Rtc.Collaboration.dll)
Syntax
'Declaration
Public Function BeginStartup ( _
userCallback As AsyncCallback, _
state As Object _
) As IAsyncResult
'Usage
Dim instance As CollaborationPlatform
Dim userCallback As AsyncCallback
Dim state As Object
Dim returnValue As IAsyncResult
returnValue = instance.BeginStartup(userCallback, _
state)
public IAsyncResult BeginStartup(
AsyncCallback userCallback,
Object state
)
Parameters
- userCallback
Type: System.AsyncCallback
The method to be called when the asynchronous operation is completed.
- state
Type: System.Object
A user-provided object that distinguishes this particular asynchronous operation from other asynchronous operations.
Return Value
Type: System.IAsyncResult
An IAsyncResult that references the asynchronous operation.
Exceptions
Exception | Condition |
---|---|
InvalidOperationException | Thrown when the platform has already been started or has been terminated. |
Remarks
Once the platform is started up it can be used to create endpoints. In case of auto-provisioned CollaborationPlatform the provisioning information for the application is fetched during startup. It also subscribes to changes in provisioning information such as addition or removal of application endpoint owners, changes to configured certificate, etc.
Examples
The following example shows how to start a server platform that uses auto-provisioning. The example assumes the server has been configured to support provisioning of the application.
C# Server platform initialization with provisioning
private void PlatformStartupCompleted(IAsyncResult result)
{
try
{
CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;
platform.EndStartup(result);
Console.WriteLine("Platform started.");
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Platform startup failed: {0}", exception.Message);
}
finally
{
// TODO: Put any clean up code here.
}
}
private void Platform_ApplicationEndpointOwnerDiscovered(
object sender/*platform*/,
ApplicationEndpointSettingsDiscoveredEventArgs e)
{
try
{
CollaborationPlatform platform = sender as CollaborationPlatform;
// A new endpoint was added. The configured settings can be retrieved.
ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;
// Customize additional settings if required
settings.OwnerPhoneUri = "tel:+14255553333";
ApplicationEndpoint endpoint = new ApplicationEndpoint(platform, settings);
// Save the active endpoint in the list.
m_endpoints.Add(endpoint);
// Register event handlers
endpoint.RegisterForIncomingCall<InstantMessagingCall>(this.InstantMessagingCallReceived);
endpoint.StateChanged += this.Endpoint_StateChanged;
endpoint.OwnerPropertiesChanged += this.Endpoint_OwnerPropertiesChanged;
endpoint.BeginEstablish(this.EndpointEstablishCompleted, endpoint/*state*/);
}
catch (InvalidOperationException)
{
// Platform was shutdown on another thread
// TODO: Replace with error handling code.
Console.WriteLine("Could not establish endpoint. Platform was not in a valid state.");
}
}
private void Endpoint_StateChanged(object sender /*endpoint*/, LocalEndpointStateChangedEventArgs e)
{
// When the endpoint is terminated because of a contact being deleted,
// the application receives Terminating and Terminated state changes.
Console.WriteLine("Endpoint state changed from {0} to {1}", e.PreviousState.ToString(), e.State.ToString());
}
private void Endpoint_OwnerPropertiesChanged(object sender /*endpoint*/, ApplicationEndpointOwnerPropertiesChangedEventArgs e)
{
// When owner properties data for the endpoint changes the OwnerPropertiesChanged event is raised,
// so find out what has changed.
}
private void EndpointEstablishCompleted(IAsyncResult result)
{
try
{
LocalEndpoint endpoint = result.AsyncState as LocalEndpoint;
endpoint.EndEstablish(result);
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Failed to establish endpoint: {0}", exception.Message);
}
finally
{
// TODO: Add clean up code here.
}
}
The following example shows how to start a server platform that uses auto-provisioning. The example assumes the server has been configured to support provisioning of the application.
C# Server platform initialization with provisioning
private void PlatformStartupCompleted(IAsyncResult result)
{
try
{
CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;
platform.EndStartup(result);
Console.WriteLine("Platform started.");
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Platform startup failed: {0}", exception.Message);
}
finally
{
// TODO: Put any clean up code here.
}
}
The following example shows how to start a server platform that uses auto-provisioning. The example assumes the server has been configured to support provisioning of the application.
C# Server platform initialization with provisioning
private void PlatformStartupCompleted(IAsyncResult result)
{
try
{
CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;
platform.EndStartup(result);
Console.WriteLine("Platform started.");
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Platform startup failed: {0}", exception.Message);
}
finally
{
// TODO: Put any clean up code here.
}
}