Create a Multiparty IM Session and Add a Participant
The following code examples demonstrate how to set up a Multiparty IM (MIM) session and add a participant to the session. The operations in the Initialize RTC code example must be performed before using this example.
Note This example does not contain error checking or releases appropriate for real code.
C++ Code Example
IRTCSession *pIRTCSession = NULL; IRTCParticipant *pIRTCParty = NULL; BSTR bstrDestURI = SysAllocString(L"someone@microsoft.com"); BSTR bstrDestName = SysAllocString(L"Jeff Smith"); // When you create the session, you can specify a profile // if one is required. In this code example, no profile is // specified. The RTC Client API will choose the best profile. hr = pIRTCClient->CreateSession(RTCST_MULTIPARTY_IM, NULL, NULL, 0, &pIRTCSession); // If (hr != S_OK), process the error here. // Add the participant. hr = pIRTCSession->AddParticipant(bstrDestURI, bstrDestName, &PIRTCParty); // If (hr != S_OK), process the error here. // Wait for the RTCE_SESSION_STATE_CHANGE event of // type RTCSS_CONNECTED before attempting to perform // operations on the session. // Alternatively, you can call IRTCSession::SendMessage() // before the session is connected. The RTC Client API // will queue the message and send it once the // session is connected.
Visual Basic Code Example
Dim objSession As IRTCSession Dim objParticipant As IRTCParticipant Dim strDestURI As String '(for example, someone@microsoft.com) Dim strDestName As String '(for example, Jeff Smith) 'Create a MULTIPARTY_IM session. Set objSession = objRTCClient.CreateSession(RTCST_MULTIPARTY_IM, _ "", _ Nothing, _ 0) ' If (Err.Number), process the error here. 'Add a participant to the IM session. Set objParticipant = objSession.AddParticipant(strDestURI, _ strDestName) ' Wait for the RTCE_SESSION_STATE_CHANGE event of ' type RTCSS_CONNECTED before attempting to perform ' operations on the session. ' Alternatively, you can call IRTCSession::SendMessage() before ' the session is connected. The RTC Client API will queue the ' message and send it once the session is connected.