개발 가이드
Local Navigation
BlackBerry Manuals & Help
>
개발자 문서
>
BlackBerry Messenger Social Platform SDK
>
개발 가이드
BlackBerry Messenger SDK - 1.2
채널 수신기 정의
다음 코드 샘플에서는 채널 수신기가 필요한 프로그램의 일부로 이 클래스를 생성한다고 가정합니다.
- 필요한 클래스와 인터페이스를 가져옵니다.
import net.rim.blackberry.api.bbm.platform.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*;
- 채널 수신기의 프레임워크를 생성하고 각 콜백 메서드의 서명을 정의합니다. 다음 코드 샘플은 발생한 이벤트를 나타내는 메시지를 보여줍니다.
class MyChannelListener extends BBMPlatformChannelListener { public void invitationAccepted(BBMPlatformConnection connection, BBMPlatformContact contact) { Dialog.inform(contact.getDisplayName() + " has accepted your invitation."); } public void invitationDeclined(BBMPlatformConnection connection, String contactDisplayName) { Dialog.inform(contactDisplayName + " has declined your invitation."); } public void invitationFailed(BBMPlatformConnection connection, String inviteeName, int reasonCode) { Dialog.inform(inviteeName + " has failed to receive your invitation. Error: " + reasonCode); } public void contactLeft(BBMPlatformConnection connection, BBMPlatformContact contact) { Dialog.inform(contact.getDisplayName() + " has left the application."); } //NOTE: The message parameter is received as a data array. This method converts message to a String before displaying. public void dataReceived(BBMPlatformConnection connection, BBMPlatformContact fromContact, BBMPlatformData message) { Dialog.inform(fromContact.getDisplayName() + ": " + new String(message.getData())); } //NOTE: param is a custom parameter defined by the application and passed in from the sender of the invitation public void invitationReceived(BBMPlatformConnection connection, BBMPlatformContact contact, String param) { Dialog.inform(contact.getDisplayName() + ": " + param); } public void invitationsSent(BBMPlatformConnection connection, int count) { Dialog.inform("I've sent " + count + " invitations."); } public void joinFailed(BBMPlatformConnection connection, BBMPlatformContact inviter, int reasonCode) { Dialog.inform("The user has failed to join the session. Error: " + reasonCode); } }
다음 주제: 메시징 서비스 수신기 정의
이전 주제: 서비스 수신기 정의