|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Session
An object to be used for communication between BlackBerry Messenger contacts.
Sessions
have three main states:
STATE_CLOSED
: The Session
is closed and cannot be used for any sort of communication. To open
a Session
, the #sendRequest()
method must be invoked. This method will send a request to the MessengerContact
associated with this Session
and the state will transition to STATE_REQUESTING
.STATE_REQUESTING
: A request to open this Session
has been sent. This Session
cannot
be used for any sort of communication.STATE_OPEN
: The Session
is open and can be used to send data to the associated
MessengerContact
. To close this session, use the Session.close()
method.
Field Summary | ||
---|---|---|
|
static int |
STATE_CLOSED
A state variable indicating that this Session is currently closed. |
|
static int |
STATE_OPEN
A state variable indicating that this Session is currently open. |
|
static int |
STATE_REQUESTING
A state variable indicating that a request to open this Session has been sent. |
Method Summary | ||
---|---|---|
|
void |
addListener(SessionListener listener,
ApplicationDescriptor application)
Adds a SessionListener to this Session . |
|
void |
close()
Closes this Session . |
|
void |
display(String text)
Displays a string in the conversation window for the MessengerContact associated with this Session . |
|
void |
display(String text,
Field field)
Displays a Field object in the conversation window for the MessengerContact associated with this Session . |
|
MessengerContact |
getContact()
Returns the MessengerContact associated with this Session . |
|
int |
getState()
Returns the state of this Session . |
|
boolean |
isOpen()
Whether this Session is open or not. |
|
void |
removeListener(SessionListener listener)
Removes a SessionListener from this Session . |
|
void |
send(Message message)
Sends data to this Session 's corresponding MessengerContact |
|
void |
sendRequest(SessionSetupListener listener,
ApplicationDescriptor application,
String url)
Sends a message to this Session 's MessengerContact to request that this Session be opened. |
Field Detail |
---|
static final int STATE_CLOSED
Session
is currently closed.
static final int STATE_REQUESTING
Session
has been sent.
static final int STATE_OPEN
Session
is currently open.
Method Detail |
---|
boolean isOpen()
Session
is open or not.
true
if this Session
is open, false
otherwise.int getState()
Session
.
Session
.void close()
Session
. Applications will no longer be able to send data using this Session
.
The remote user's application will be notified and their corresponding Session
will also be closed.
void send(Message message)
Session
's corresponding MessengerContact
message
- A Message
containing information to be sent.
IllegalStateException
- If this Session
is closed.void addListener(SessionListener listener, ApplicationDescriptor application)
SessionListener
to this Session
.
listener
- The listener to be added. If this listener has already been added this method does nothing.application
- An ApplicationDescriptor
describing your application. Your application will be started using
the descriptor before notifications are passed to the corresponding listener.
IllegalArgumentException
- If application is null or does not describe the registering application, or if listener is null.void removeListener(SessionListener listener)
SessionListener
from this Session
. If the SessionListener
is not already added,
this method does nothing.
listener
- The listener to be removed.void sendRequest(SessionSetupListener listener, ApplicationDescriptor application, String url)
Session
's MessengerContact
to request that this Session
be opened.
After calling this method the state of this Session
will be set to STATE_REQUESTING
. If the remote user
accepts the request, the state will be set to STATE_OPEN
. If the remote user declines, or if there is another error, the state will return to
STATE_CLOSED
.
listener
- A SessionSetupListener
that will be notified of the request's status. Must not be null.application
- An ApplicationDescriptor
that describes your application. Your application will be started
using the descriptor before any listener events are given to the specified SessionSetupListener
.
The application provided must be named uniquely, and the remote contact's device must have already registered an application
with the same unique name with a SessionRequestListener
for the request to complete successfully.
url
- If the remote user does not have an application on their device that has registered the same unique name as this application,
the URL will be displayed to the remote user. The URL should provide the user the ability to download this application.
url
can be null
if no URL is needed.
IllegalStateException
- If this Session
is in the STATE_REQUESTING
state.
IllegalArgumentException
- If listener is null, if application is null or if application does not describe the calling applicationvoid display(String text)
MessengerContact
associated with this Session
.
text
- The text to display in the conversation window
IllegalStateException
- If this Session
is closed.void display(String text, Field field)
Field
object in the conversation window for the MessengerContact
associated with this Session
.
text
- A textual description of the field. To be used as a preview in the contact list screen.field
- The Field
to display in the conversation window.
IllegalStateException
- If this Session
is closed.MessengerContact getContact()
MessengerContact
associated with this Session
.
MessengerContact
object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal