This documentation is archived and is not being maintained.

Registering an Endpoint

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Registering an endpoint entails creating a SipEndpoint instance, and then registering this instance with a SIP registrar server (SipEndpoint has been designed to register with Office Communications Server 2007, and has been tested only against this platform). To create an endpoint object, an application can choose to use the default connection manager or create one and pass it to an endpoint constructor along with other input parameters.

After a SipEndpoint has been created, it must be registered with a SIP server. For more information, see Registering a SipEndpoint.

Because a SipEndpoint must register itself with a SIP registrar server, the minimum requirement to create such an endpoint involves specifying the SIP URI of the local user, an authentication protocol, transport type, and registration server name (that is, by using the SipEndpoint constructor that takes four arguments).

Alternatively, the application can use the other constructor, specifying the same arguments already mentioned, together with additional arguments specifying the port number (0 means use default ports: 5060 for TCP and 5061 for TLS), a connection manager (can be null), and an endpoint ID.

After an endpoint is created, an application typically subscribes to some events raised by the RealTimeEndpoint class. Endpoint event registration and handling are illustrated in the following code examples.

string userName = "Nattorn Jayanama";
string password = ...;   // A user-supplied value
string domain = "contoso.com";
string realm = SipEndpoint.DefaultRtcRealm; // Sets realm to "SIP Communications Service"
string sipUri = "sip:Jayanama@contoso.com";
string sipServerName = "sales.contoso.com";
SipAuthenticationProtocols authProtocol = SipAuthenticationProtocols.Ntlm | SipAuthenticationProtocols.Kerberos;
TransportType transportType = SipTransportType.Tcp;
int port = 5060; // Port used for TCP
bool allowNoAuthentication = false;
string endpointId = null;  // Let the API assign the endpoint ID value.
bool useConnectionManager = true;
RealTimeConnectionManager connectionManager = ...; // Assumed to be created elsewhere

endpoint = new SipEndpoint(sipUri,
                           authProtocol,
                           transportType,
                           sipServerName,
                           port,
                           allowNoAuthentication,
                           connectionManager,
                           endpointId);

// DisplayName can be an empty string. If the display name does not match
// the name stored in Active Directory for this user, 
// Office Communications Server 2007 overwrites
// this property in messages as they are routed.
endpoint.DisplayName = "Nattorn Jayanama";
endpoint.ApplicationUserAgent = "My application";

NetworkCredential credential = new NetworkCredential(
            userName, password, domain);

if (useClientConnectionManager) 
{
  // Create a security association
  endpoint.CredentialCache.Add(realm, credential);

  // The following setting limits this endpoint to 20 transactions 
  // at a time. (This is also the default setting.)
  endpoint.IsEndpointThrottled = true; 
}

else
{
  // With a server connection manager, an application will
  // typically need to support more than 20 transactions
  // at a time. Thus, you need to set the IsEndpointThrottled property
  // to false.
  // If throttling is disabled, Office Communications Server 2007 
  // should also be configured to trust this application server and
  // not throttle.
  endpoint.IsEndpointThrottled = false; 
}

// Register to receive endpoint events
endpoint.SessionReceived += new EventHandler<SessionReceivedEventArgs>(endpoint_SessionReceived);
endpoint.MessageReceived += new EventHandler<MessageReceivedEventArgs>(endpoint_MessageReceived);

The following code example illustrates the patterns for handling endpoint events. The first method definition is a skeleton of the handler for the MessageReceived event. The second method definition is a skeleton of the handler for the SessionReceived event.

void endpoint_MessageReceived(object sender, MessageReceivedEventArgs e)
{
  // Handle the receipt of page mode messages
}

void endpoint_SessionReceived(object sender, SessionReceivedEventArgs e)
{
  SignalingSession sipSession = e.Session;
  // Handle the incoming session, implementation given elsewhere.
}
Show: