Partager via


Create a Session and Make a Call

The following code example shows how to make a call. The session is created, then a participant is added to the session to initiate the call. The operations in the Initialize the Communications Service example must be performed before using this code.

**Note   **This code has not been thoroughly tested, does not contain error checking, and is not intended for production use.

HRESULT hr = S_OK;
BSTR bstrLocalURI = NULL;
BSTR bstrDestURI = NULL;
RTC_SESSION_TYPE SessionType;
SessionType = // Specify session type 
// For phone-phone sessions, the local telephone URI is required.
if (SessionType == RTCST_PHONE_TO_PHONE)
{
    bstrLocalURI = SysAllocString(_T("tel:+14257034556"));
}
// Get the URI to call; this can be a SIP or a TEL URI.
bstrDestURI = SysAllocString(_T("sip:someone@example.com")); 
// Create the session with the specified session type and local URI.
hr = pIRTCClient->CreateSession( SessionType, 
                                 bstrLocalURI, 
                                 NULL,
                                 &pIRTCSession );
// if (hr != S_OK) process error here.
// The AddParticipant method sets the session into the active state
// and creates the IRTCParticipant interface. 
IRTCParticipant *pIRTCParticipant;
hr = pIRTCSession->AddParticipant( bstrDestURI, 
                                   NULL, 
                                   &pIRTCParticipant );
// if (hr != S_OK) process error here.

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.