|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface SessionProtocol
A protocol for sending session messages and channel messages to a client.
The implementation of the protocol is only responsible for the formating and sending of messages to the client. Unless otherwise noted, the implementation is not required to perform validity checks on method arguments. For calls that result in messages sent to a client, is up to the caller to make sure arguments contain valid information. It is up to the client to decide what it wants to do if it receives messages that seem nonsensical.
If a protocol specification requires that a login acknowledgment be delivered to a client before any other protocol messages, the protocol must implement this requirement. It is possible that a caller may request that other messages be sent before a login acknowledgment, and if the protocol requires, these messages should be enqueued until the login acknowledgment has been sent to the client.
| Nested Class Summary | |
|---|---|
static class |
SessionProtocol.DisconnectReason
Reasons why a server disconnects a session. |
| Method Summary | |
|---|---|
void |
channelJoin(String name,
BigInteger channelId,
Delivery delivery)
Notifies the associated client that it is joined to the channel with the specified name and channelId. |
void |
channelLeave(BigInteger channelId)
Notifies the associated client that it is no longer a member of the channel with the specified channelId. |
void |
channelMessage(BigInteger channelId,
ByteBuffer message,
Delivery delivery)
Sends the associated client the specified channel message
for the channel with the specified channelId in a manner
that satisfies the specified delivery guarantee. |
void |
disconnect(SessionProtocol.DisconnectReason reason)
Disconnects the associated session for the specified reason. |
Set<Delivery> |
getDeliveries()
Returns a set containing the delivery guarantees supported by this protocol. |
int |
getMaxMessageLength()
Returns the maximum length, in bytes, of the buffers passed as the message parameters to the
sessionMessage and
channelMessage methods. |
void |
sessionMessage(ByteBuffer message,
Delivery delivery)
Sends the associated client the specified message in a
manner that satisfies the specified delivery guarantee. |
| Methods inherited from interface java.nio.channels.Channel |
|---|
close, isOpen |
| Method Detail |
|---|
Set<Delivery> getDeliveries()
int getMaxMessageLength()
message parameters to the
sessionMessage and
channelMessage methods.
void sessionMessage(ByteBuffer message,
Delivery delivery)
throws IOException
message in a
manner that satisfies the specified delivery guarantee.
When possible, the message should be delivered using the most
efficient means (e.g., protocol and transport) to satisfy the
delivery guarantee. However, a stronger delivery guarantee may be
used to deliver the message if this protocol only supports
stronger delivery guarantees. If this protocol is not able to
satisfy the specified delivery guarantee (e.g., only supports weaker
delivery guarantees than the one specified), then a DeliveryNotSupportedException will be thrown.
The ByteBuffer is not modified and may be reused
immediately after this method returns. Changes made to the buffer
after this method returns will have no effect on the message sent to
the client by this invocation.
message - a messagedelivery - the delivery guarantee
IllegalArgumentException - if the message size is
greater than getMaxMessageLength()
IllegalStateException - if the associated session was
requested to suspend messages
DeliveryNotSupportedException - if the specified delivery guarantee cannot be satisfied by this protocol
IOException - if an I/O error occurs
void channelJoin(String name,
BigInteger channelId,
Delivery delivery)
throws IOException
name and channelId. This
notification to the client must be delivered reliably.
name - a channel namechannelId - the channel's IDdelivery - the channel's delivery guarantee
IllegalStateException - if the associated session was
requested to suspend messages (explicitly or due to
relocation)
DeliveryNotSupportedException - if the specified delivery guarantee cannot be satisfied by this protocol
IOException - if an I/O error occurs
void channelLeave(BigInteger channelId)
throws IOException
channelId. This
notification to the client must be delivered reliably.
channelId - a channel ID
IllegalStateException - if the associated session was
requested to suspend messages (explicitly or due to
relocation)
IOException - if an I/O error occurs
void channelMessage(BigInteger channelId,
ByteBuffer message,
Delivery delivery)
throws IOException
message
for the channel with the specified channelId in a manner
that satisfies the specified delivery guarantee.
When possible, the message should be delivered using the most
efficient means (e.g., protocol and transport) to satisfy the
delivery guarantee. However, a stronger delivery guarantee may be
used to deliver the message if this protocol only supports
stronger delivery guarantees. If this protocol is not able to
satisfy the specified delivery guarantee (e.g., only supports weaker
delivery guarantees than the one specified), then a DeliveryNotSupportedException will be thrown.
The ByteBuffer is not modified and may be reused
immediately after this method returns. Changes made to the buffer
after this method returns will have no effect on the message sent to
the client by this invocation.
channelId - a channel IDmessage - a channel messagedelivery - the channel's delivery guarantee
IllegalArgumentException - if the message size is
greater than getMaxMessageLength()
IllegalStateException - if the associated session was
requested to suspend messages (explicitly or due to
relocation)
DeliveryNotSupportedException - if the specified delivery guarantee cannot be satisfied by this protocol
IOException - if an I/O error occurs
void disconnect(SessionProtocol.DisconnectReason reason)
throws IOException
reason.
The protocol may send a message to the associated client indicating
the reason for the disconnection, or the protocol may close the
connection immediately. Any underlying connection(s) should be
closed in a timely fashion.
reason - the reason for disconnection
IOException - if an I/O error occurs
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||