| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgcs.GcsConnection
public abstract class GcsConnection
Represents an abstraction of connection with the RestGroups communication system.
 Connecting and disconnecting from the RestGroups server can be accomplished
 by calling
 connect(GcsSettings, String, boolean, boolean) and
 disconnect() methods, respectively.
 
 The multicast(GcsMessage) and
 multicast(GcsMessage[]) methods are used to send
 messages encapsulated with GcsMessage to other RestGroups users.
 
 To check the availability of new messages the poll()
 method should be used. receive() and
 receive(int) are blocking methods which can be used to
 retrieve new messages from the RestGroups server.
 
 Messages can also be received through a listener. The listener class has to
 implement GcsAdvancedMessageListener or
 GcsBasicMessageListener interface and be added to the GcsConnection
 with add(GcsAdvancedMessageListener) or
 add(GcsBasicMessageListener) methods, respectively.
| Constructor Summary | |
|---|---|
protected  | 
GcsConnection()
Empty constructor, provided for convenience.  | 
| Method Summary | |
|---|---|
abstract  void | 
add(GcsAdvancedMessageListener listener)
Sets up the GcsAdvancedMessageListener listener. | 
abstract  void | 
add(GcsBasicMessageListener listener)
Sets up the GcsBasicMessageListener listener. | 
abstract  void | 
connect(GcsSettings settings,
        java.lang.String privateName,
        boolean priority,
        boolean groupMembership)
Allows connecting to the RestGroups server.  | 
abstract  void | 
disconnect()
Allows disconnecting from the RestGroups server.  | 
abstract  GcsGroup | 
getPrivateGroup()
Returns the GcsGroup object representing the private group for
 this connection. | 
abstract  void | 
multicast(GcsMessage message)
Sends the message encapsulated in the GcsMessage object to groups
 specified in this object. | 
abstract  void | 
multicast(GcsMessage[] messages)
Sends multiple messages encapsulated in the GcsMessage objects to
 groups specified inside those objects. | 
abstract  boolean | 
poll()
Checks for unread messages for this connection.  | 
abstract  GcsMessage | 
receive()
Returns next unread message for this connection if available.  | 
abstract  GcsMessage[] | 
receive(int numMessages)
Returns next numMessages for this connection if available.  | 
abstract  void | 
remove(GcsAdvancedMessageListener listener)
Deactivates the GcsAdvancedMessageListener listener for this
 connection. | 
abstract  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 | 
|---|
protected GcsConnection()
| Method Detail | 
|---|
public abstract void add(GcsAdvancedMessageListener listener)
                  throws GcsException
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.
listener - object implementing the GcsAdvancedMessageListener
            interface
GcsExceptionremove(GcsAdvancedMessageListener)
public abstract void add(GcsBasicMessageListener listener)
                  throws GcsException
GcsBasicMessageListener listener. Once it is done,
 every time a regular message is received,
 GcsBasicMessageListener.messageReceived(GcsMessage) method is
 called. Membership messages are omitted.
listener - object implementing the GcsBasicMessageListener
            interface
GcsExceptionremove(GcsBasicMessageListener)
public abstract void connect(GcsSettings settings,
                             java.lang.String privateName,
                             boolean priority,
                             boolean groupMembership)
                      throws GcsException
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 established
public abstract void disconnect()
                         throws GcsException
GcsException - if difficulties during disconnecting from the RestGroups
             server were encountered or the connection has not been
             established
public abstract GcsGroup getPrivateGroup()
                                  throws GcsException
GcsGroup object representing the private group for
 this connection.
GcsException
public abstract void multicast(GcsMessage message)
                        throws GcsException
GcsMessage object to groups
 specified in this object.
message - a message to be send
GcsException - if errors were encountered during sending the message or the
             connection is broken
public abstract void multicast(GcsMessage[] messages)
                        throws GcsException
GcsMessage objects to
 groups specified inside those objects.
messages - array of messages to be send
GcsException - if errors were encountered during sending the messages or the
             connection is broken
public abstract boolean poll()
                      throws GcsException
GcsException - if errors were encountered during checking for new messages
             or the connection is broken
public abstract GcsMessage receive()
                            throws GcsException,
                                   java.io.InterruptedIOException
GcsException - if errors were encountered during reception of the message or
             the connection is broken
java.io.InterruptedIOException
public abstract GcsMessage[] receive(int numMessages)
                              throws GcsException,
                                     java.io.InterruptedIOException
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 abstract void remove(GcsAdvancedMessageListener listener)
                     throws GcsException
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
 receive() (receive(int)) called.
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.add(GcsAdvancedMessageListener)
public abstract void remove(GcsBasicMessageListener listener)
                     throws GcsException
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 (receive() (
 receive(int)) called.
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.add(GcsBasicMessageListener)
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||