| java.lang.Object com.sun.midp.io.j2me.ProtocolBase com.sun.midp.io.j2me.cbs.Protocol
Protocol | public class Protocol extends ProtocolBase (Code) | | CBS message connection implementation.
Cell Broadcast message connections are receive only.
|
Constructor Summary | |
public | Protocol() Creates a message connection protocol handler. |
Method Summary | |
protected void | checkReceivePermission() Checks the internal setting of the receive permission. | public void | close() Closes the connection. | protected int | close00(int connHandle, int deRegister) Close connection.
Parameters: connHandle - handle returned by open0 Parameters: deRegister - Deregistration appID when parameter is 1. | protected String | getAppID() Gets the connection parameter in string mode. | public Message | newMessage(String type) Constructs a new message object of a binary or text type.
If the TEXT_MESSAGE constant is passed in, the
TextMessage interface is implemented by the created object.
If the BINARY_MESSAGE constant is passed in, the
BinaryMessage interface is implemented by the created
object. | public Message | newMessage(String type, String addr) Constructs a new message object of a text or binary type and specifies
a destination address.
If the TEXT_MESSAGE constant is passed in, the
TextMessage interface is implemented by the created object.
If the BINARY_MESSAGE constant is passed in, the
BinaryMessage interface is implemented by the created
object.
The destination address addr has the following format:
cbs://phone_number:port
Parameters: type - TEXT_MESSAGE orBINARY_MESSAGE . Parameters: addr - The destination address of the message. | public int | numberOfSegments(Message message) Returns the number of segments required to send the given
Message .
Note: The message is not actually sent. | public DataInputStream | openDataInputStream() Open and return a data input stream for a connection. | public DataOutputStream | openDataOutputStream() Open and return a data output stream for a connection. | public InputStream | openInputStream() Open and return an input stream for a connection. | public OutputStream | openOutputStream() Open and return an output stream for a connection. | public Connection | openPrim(String name, int mode, boolean timeouts) Opens a CBS connection. | public synchronized Connection | openPrimInternal(String name, int mode, boolean timeouts) Opens a CBS connection. | public synchronized Message | receive() Receives the bytes that have been sent over the connection,
constructs a Message object, and returns it. | public void | send(Message msg) Cell broadcast connections are read-only connections. | protected void | setAppID(String newValue) Sets the connection parameter in string mode. | protected int | unblock00(int msid) Unblock the receive thread.
Parameters: msid - The MIDlet suite ID. | protected int | waitUntilMessageAvailable00(int handle) |
GSM_BINARY | final protected static int GSM_BINARY(Code) | | DCS: Binary
|
GSM_TEXT | final protected static int GSM_TEXT(Code) | | DCS: GSM Alphabet
|
GSM_UCS2 | final protected static int GSM_UCS2(Code) | | DCS: Unicode UCS-2
|
openConnections | protected static Vector openConnections(Code) | | Currently opened connections.
|
Protocol | public Protocol()(Code) | | Creates a message connection protocol handler.
|
checkReceivePermission | protected void checkReceivePermission() throws InterruptedIOException(Code) | | Checks the internal setting of the receive permission. Called from
the receive and setMessageListener methods.
exception: InterruptedIOException - if permission dialog was pre-empted. |
close | public void close() throws IOException(Code) | | Closes the connection. Resets the connection open flag to
false . Subsequent operations on a closed connection should
throw an appropriate exception.
exception: IOException - if an I/O error occurs |
close00 | protected int close00(int connHandle, int deRegister)(Code) | | Close connection.
Parameters: connHandle - handle returned by open0 Parameters: deRegister - Deregistration appID when parameter is 1. 0 on success, -1 on failure |
getAppID | protected String getAppID()(Code) | | Gets the connection parameter in string mode.
string that contains a parameter |
newMessage | public Message newMessage(String type)(Code) | | Constructs a new message object of a binary or text type.
If the TEXT_MESSAGE constant is passed in, the
TextMessage interface is implemented by the created object.
If the BINARY_MESSAGE constant is passed in, the
BinaryMessage interface is implemented by the created
object.
If this method is called in a sending mode, a new Message
object is requested from the connection. For example:
Message msg = conn.newMessage(TEXT_MESSAGE);
The Message object that was created doesn't have the
destination address set. It's the application's responsibility to set it
before the message is sent.
If this method is called in receiving mode, the
Message object does have
its address set. The application can act on the object to extract
the address and message data.
Parameters: type - TEXT_MESSAGE orBINARY_MESSAGE . A new CBS Message object. |
newMessage | public Message newMessage(String type, String addr)(Code) | | Constructs a new message object of a text or binary type and specifies
a destination address.
If the TEXT_MESSAGE constant is passed in, the
TextMessage interface is implemented by the created object.
If the BINARY_MESSAGE constant is passed in, the
BinaryMessage interface is implemented by the created
object.
The destination address addr has the following format:
cbs://phone_number:port
Parameters: type - TEXT_MESSAGE orBINARY_MESSAGE . Parameters: addr - The destination address of the message. A new CBS Message object. |
numberOfSegments | public int numberOfSegments(Message message)(Code) | | Returns the number of segments required to send the given
Message .
Note: The message is not actually sent. The number of protocol
segments is simply computed.
This method calculates the number of segments required
when this message is split into the protocol segments
utilizing the underlying protocol's features.
Possible implementation's limitations that may limit the number of
segments that can be sent using it are not taken into account. These
limitations are protocol specific. They are documented
with that protocol's adapter definition.
Parameters: message - The message to be used for the computation. The number of protocol segments needed for sending the message.Returns 0 if the Message object cannot besent using the underlying protocol. |
openPrim | public Connection openPrim(String name, int mode, boolean timeouts) throws IOException(Code) | | Opens a CBS connection. This method is called from the
Connector.open() method to obtain the destination
address given in the name parameter.
The format for the name string for this method is:
cbs://[phone_number:][port_number]
where the phone_number: is optional. If the
phone_number parameter is present, the connection is being
opened in client mode. This means that messages can be sent. If the
parameter is absent, the connection is being opened in server mode.
This means that messages can be sent and received.
The connection that is opened is to a low-level transport mechanism
which can be any of the following:
- a datagram Short Message Peer-to-Peer (SMPP)
to a service center
- a
comm connection to a phone device with
AT-commands .
- a native CBS stack
Currently, the mode and timeouts parameters are
ignored.
Parameters: name - the target of the connection Parameters: mode - indicates whether the callerintends to write to the connection. Currently,this parameter is ignored. Parameters: timeouts - indicates whether the callerwants timeout exceptions. Currently,this parameter is ignored. this connection exception: IOException - if the connection is closed or unavailable |
openPrimInternal | public synchronized Connection openPrimInternal(String name, int mode, boolean timeouts) throws IOException(Code) | | Opens a CBS connection. This is the internal entry point that
allows the CBS protocol handler to use the reserved port for
CBS emulated messages.
Parameters: name - The name of the connection, which as a format of"//:portNumber" for CBS connections. Parameters: mode - Must be READ, only. Parameters: timeouts - Indicates whether the caller wants time-outexceptions. Currently ignored. the successfully opened connection. exception: IOException - if the connection is closed or unavailable. |
receive | public synchronized Message receive() throws IOException(Code) | | Receives the bytes that have been sent over the connection,
constructs a Message object, and returns it.
If there are no Message s waiting on the connection,
this method will block until the MessageConnection
is closed, or a message is received.
a Message object exception: java.io.IOException - if an error occurs while receivinga message. exception: java.io.InterruptedIOException - if thisMessageConnection object is closed during thecall of this method. exception: java.lang.SecurityException - if the application doesn't havepermission to receive messages on the given port. |
send | public void send(Message msg) throws IOException(Code) | | Cell broadcast connections are read-only connections. Calling this
method causes an IOException to be thrown.
Parameters: msg - Placeholder: A Message object. exception: IOException - always thrown. |
setAppID | protected void setAppID(String newValue)(Code) | | Sets the connection parameter in string mode.
Parameters: newValue - new value of connection parameter |
unblock00 | protected int unblock00(int msid) throws IOException(Code) | | Unblock the receive thread.
Parameters: msid - The MIDlet suite ID. returns handle to the connection. |
waitUntilMessageAvailable00 | protected int waitUntilMessageAvailable00(int handle) throws IOException(Code) | | Waits until message available
Parameters: handle - handle to connection 0 on success, -1 on failure exception: IOException - if an I/O error occurs |
|
|