Create a Text Messaging Session
The following code example shows how to create a text-messaging session and send an text message. 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.
IRTCSession *pIRTCSession = NULL;
IRTCParticipant *pIRTCParty = NULL;
BSTR bstrDestURI = SysAllocString(_T("someone@example.com"));
BSTR bstrDestName = SysAllocString(_T("Some One"));
BSTR bstrMsgHeader = // specify message header;
BSTR bstrMsg = // specify message ;
LONG lCookie = // set cookie value ;
// When you create the session, you can specify a profile if one is required.
// In this code, no profile is specified.
hr = pIRTCClient->CreateSession( RTCST_IM,
NULL,
NULL,
0,
&pIRTCSession );
// if (hr != S_OK) process error here.
// Add an IM session participant.
hr = pIRTCSession->AddParticipant( bstrDestURI,
bstrDestName,
m_pIRTCParty );
// if (hr != S_OK) process error here.
// Send the initial message upon which the participant [end-point]
// will receive the RTCE_SESSION_STATE_CHANGE incoming event
// from which the end-point needs to retrieve its session pointer.
// The session initiator will be in the connected state after the
// end-point successfully receives the initial message.
hr = pIRTCSession->SendMessage( bstrMsgHeader,
bstrMsg,
lCookie );
// if (hr != S_OK) process error here.
Last updated on Saturday, April 10, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.