Send a message to all participants in a session
Before you begin: Send a session invitation to a contact
to populate your session's contact list with contacts.
Code sample: Sending a message to all participants in a session
The following code sample assumes that the class that displayed the MyBBMScreen has passed a reference to the application's associated BBMPlatformContext object into the MyBBMScreen constructor.
This code sample also assumes that you have completed the task, Define a session listener, and that you named the session listener class, MySessionListener.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.service.*;
import net.rim.device.api.ui.component.*;
public class MyBBMScreen extends MainScreen
{
public MyBBMScreen(BBMPlatformContext platformContext)
{
MessagingService messagingService = platformContext.getMessagingService();
BBMPlatformSession mySession = messagingService.createSession(new MySessionListener());
if (mySession != null)
{
channel.sendInvitation("Lets play a game", "Poker App", null, 0);
BBMPlatformContactList contacts = channel.getContactList();
String myMsg = "Test data";
BBMPlatformData data = new BBMPlatformData("Message", myMsg.getBytes(), 0);
mySession.sendData(data, contacts);
}
}
}
Previous topic: Code sample: Joining a public session