세션의 모든 참가자에게 메시지 보내기
코드 샘플: 세션의 모든 참가자에게 메시지 보내기
다음 코드 샘플에서는 MyBBMScreen을 표시한 클래스가 프로그램과 연결된 BBMPlatformContext 개체에 대한 참조를 MyBBMScreen 생성자에 전달했다고 가정합니다.
또한 이 코드 샘플에서는세션 수신기 정의 작업을 완료했고 세션 수신기 클래스 이름을 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);
}
}
}
이전 주제: 코드 샘플: 공개 세션 참여