org.cometd
Interface Client


public interface Client

A Bayeux Client.

A Client instance represents a consumer/producer of messages in bayeux. A client may subscribe to channels and publish messages to channels.

Client instances should not be directly created by uses, but should be obtained via the Bayeux.getClient(String) or Bayeux#newClient(String, Receiver) methods.

Two types of client may be represented by this interface:

  • The server representation of a remote client connected via HTTP
  • A server side client

  • Method Summary
     void addListener(ClientListener listener)
               
     void deliver(Client from, java.lang.String toChannel, java.lang.Object data, java.lang.String id)
               
     void endBatch()
              End a batch of messages.
     java.lang.String getId()
               
     int getMaxQueue()
               
     java.util.Queue<Message> getQueue()
              Access the message queue.
     boolean hasMessages()
               
     boolean isLocal()
               
     void removeListener(ClientListener listener)
               
     void setMaxQueue(int max)
               
     void startBatch()
              Start a batch of messages.
     java.util.List<Message> takeMessages()
              Deprecated. use listeners
     

    Method Detail

    getId

    java.lang.String getId()

    hasMessages

    boolean hasMessages()

    takeMessages

    java.util.List<Message> takeMessages()
    Deprecated. use listeners

    Take any messages queued for a client.


    deliver

    void deliver(Client from,
                 java.lang.String toChannel,
                 java.lang.Object data,
                 java.lang.String id)

    addListener

    void addListener(ClientListener listener)

    removeListener

    void removeListener(ClientListener listener)

    isLocal

    boolean isLocal()
    Returns:
    True if the client is local. False if this client is either a remote HTTP client or a java client to a remote server.

    startBatch

    void startBatch()
    Start a batch of messages. Messages will not be delivered remotely until the corresponding endBatch is called. Batches may be nested and messages are only sent once all batches are ended.


    endBatch

    void endBatch()
    End a batch of messages. Messages will not be delivered that have been queued since the previous startBatch is called. Batches may be nested and messages are only sent once all batches are ended.


    getQueue

    java.util.Queue<Message> getQueue()
    Access the message queue.

    Returns:
    A queue that is synchronized on the Client instance.

    setMaxQueue

    void setMaxQueue(int max)
    Parameters:
    max - The size which if a client queue exceeds, forces a call to QueueListener.queueMaxed(Client, Message) to check if the message should be added. If set to -1, there is no queue limit. If set to zero, messages are not queued.

    getMaxQueue

    int getMaxQueue()


    Copyright © 2009 Dojo Foundation. All Rights Reserved.