|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgcs.GcsConnection
gcsImplementations.spreadGcs.SpreadGcsConnection
public class SpreadGcsConnection
Spread back-end implementation of the GcsConnection
.
GcsConnection
Constructor Summary | |
---|---|
SpreadGcsConnection()
|
Method Summary | |
---|---|
void |
add(GcsAdvancedMessageListener listener)
Sets up the GcsAdvancedMessageListener listener. |
void |
add(GcsBasicMessageListener listener)
Sets up the GcsBasicMessageListener listener. |
void |
connect(GcsSettings settings,
java.lang.String privateName,
boolean priority,
boolean groupMembership)
Allows connecting to the RestGroups server. |
void |
disconnect()
Allows disconnecting from the RestGroups server. |
GcsGroup |
getPrivateGroup()
Returns the GcsGroup object representing the private group for
this connection. |
void |
multicast(GcsMessage message)
Sends the message encapsulated in the GcsMessage object to groups
specified in this object. |
void |
multicast(GcsMessage[] messages)
Sends multiple messages encapsulated in the GcsMessage objects to
groups specified inside those objects. |
boolean |
poll()
Checks for unread messages for this connection. |
GcsMessage |
receive()
Returns next unread message for this connection if available. |
GcsMessage[] |
receive(int numMessages)
Returns next numMessages for this connection if available. |
void |
remove(GcsAdvancedMessageListener listener)
Deactivates the GcsAdvancedMessageListener listener for this
connection. |
void |
remove(GcsBasicMessageListener listener)
Deactivates the GcsBasicMessageListener listener for this
connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SpreadGcsConnection()
Method Detail |
---|
public void add(GcsAdvancedMessageListener listener) throws GcsException
GcsConnection
GcsAdvancedMessageListener
listener. Once it is done,
every time a membership or regular message is received
GcsAdvancedMessageListener.membershipMessageReceived(GcsMessage)
or GcsAdvancedMessageListener.regularMessageReceived(GcsMessage)
method is called, respectively.
add
in class GcsConnection
listener
- object implementing the GcsAdvancedMessageListener
interface
GcsException
GcsConnection.remove(GcsAdvancedMessageListener)
public void add(GcsBasicMessageListener listener) throws GcsException
GcsConnection
GcsBasicMessageListener
listener. Once it is done,
every time a regular message is received,
GcsBasicMessageListener.messageReceived(GcsMessage)
method is
called. Membership messages are omitted.
add
in class GcsConnection
listener
- object implementing the GcsBasicMessageListener
interface
GcsException
GcsConnection.remove(GcsBasicMessageListener)
public void connect(GcsSettings settings, java.lang.String privateName, boolean priority, boolean groupMembership) throws GcsException
GcsConnection
connect
in class GcsConnection
settings
- stores parameters concerning the RestGroups serverprivateName
- name describing this connections userpriority
- defines if this is a priority connectiongroupMembership
- defines if the membership messages are being received on this
connection
GcsException
- if the connection could not be establishedpublic void disconnect() throws GcsException
GcsConnection
disconnect
in class GcsConnection
GcsException
- if difficulties during disconnecting from the RestGroups
server were encountered or the connection has not been
establishedpublic GcsGroup getPrivateGroup() throws GcsException
GcsConnection
GcsGroup
object representing the private group for
this connection.
getPrivateGroup
in class GcsConnection
GcsException
public void multicast(GcsMessage message) throws GcsException
GcsConnection
GcsMessage
object to groups
specified in this object.
multicast
in class GcsConnection
message
- a message to be send
GcsException
- if errors were encountered during sending the message or the
connection is brokenpublic void multicast(GcsMessage[] messages) throws GcsException
GcsConnection
GcsMessage
objects to
groups specified inside those objects.
multicast
in class GcsConnection
messages
- array of messages to be send
GcsException
- if errors were encountered during sending the messages or the
connection is brokenpublic boolean poll() throws GcsException
GcsConnection
poll
in class GcsConnection
GcsException
- if errors were encountered during checking for new messages
or the connection is brokenpublic GcsMessage receive() throws GcsException, java.io.InterruptedIOException
GcsConnection
receive
in class GcsConnection
GcsException
- if errors were encountered during reception of the message or
the connection is broken
java.io.InterruptedIOException
public GcsMessage[] receive(int numMessages) throws GcsException, java.io.InterruptedIOException
GcsConnection
receive
in class GcsConnection
numMessages
- number of messages to be returned
GcsException
- if errors were encountered during reception of the messages
or the connection is broken
java.io.InterruptedIOException
public void remove(GcsAdvancedMessageListener listener) throws GcsException
GcsConnection
GcsAdvancedMessageListener
listener for this
connection. Once its done, both membership and regular messages will be
stored on the server until the listener will be setup again or method
GcsConnection.receive()
(GcsConnection.receive(int)
) called.
remove
in class GcsConnection
listener
- the listener to be removed from this connection
GcsException
- if errors were encountered during removal of the listener or
if it was never set up.GcsConnection.add(GcsAdvancedMessageListener)
public void remove(GcsBasicMessageListener listener) throws GcsException
GcsConnection
GcsBasicMessageListener
listener for this
connection. Once its done, regular messages will be stored on the server
until the listener will be setup again or method (GcsConnection.receive()
(
GcsConnection.receive(int)
) called.
remove
in class GcsConnection
listener
- the listener to be removed from this connection
GcsException
- if errors were encountered during removal of the listener or
if it was never set up.GcsConnection.add(GcsBasicMessageListener)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |