dojox.cometd
Interface Client

All Known Implementing Classes:
BayeuxClient

public interface Client

A Bayeux Client.

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.

Three types of client may be represented by this interface:

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

  • Method Summary
     void addListener(EventListener listener)
               
     void deliver(Client from, Message message)
              Deprecated. use deliver(Client, String, Object, String)
     void deliver(Client from, String toChannel, Object data, String id)
               
     void endBatch()
              End a batch of messages.
     String getId()
               
     Listener getListener()
              Deprecated. Returns only the first listener added
     boolean hasMessages()
               
     boolean isLocal()
               
     void publish(String toChannel, Object data, String msgId)
              Deprecated. use Channel.publish(Client, Object, String)
     void removeListener(EventListener listener)
               
     void setListener(Listener listener)
              Deprecated. use addListener(EventListener)
     void startBatch()
              Start a batch of messages.
     void subscribe(String toChannel)
              Deprecated. use Channel.subscribe(Client)
     List<Message> takeMessages()
              Take any messages queued for a client.
     void unsubscribe(String toChannel)
              Deprecated. use Channel.unsubscribe(Client)
     

    Method Detail

    getId

    String getId()

    publish

    void publish(String toChannel,
                 Object data,
                 String msgId)
    Deprecated. use Channel.publish(Client, Object, String)

    Publish data from this client. This is equivalent to Bayeux.publish(Client, String, Object, String) with this client passed as the fromClient.

    Parameters:
    data - The data itself which must be an Object that can be encoded with JSON.
    toChannel - The Channel ID to which the data is targetted
    msgId - optional message ID or null for automatic generation of a message ID.

    subscribe

    void subscribe(String toChannel)
    Deprecated. use Channel.subscribe(Client)

    Subscribe this client to a channel. This is equivalent to Bayeux.subscribe(String, Client) with this client passed. Equivalent to getChannel(toChannel).subscribe(subscriber).

    Parameters:
    toChannel -

    unsubscribe

    void unsubscribe(String toChannel)
    Deprecated. use Channel.unsubscribe(Client)

    Unsubscribe this client from a channel. This is equivalent to Bayeux.unsubscribe(String, Client) with this client passed.

    Parameters:
    toChannel -

    hasMessages

    boolean hasMessages()

    takeMessages

    List<Message> takeMessages()
    Take any messages queued for a client.


    deliver

    void deliver(Client from,
                 Message message)
    Deprecated. use deliver(Client, String, Object, String)

    Deliver a message to this client only Deliver a message directly to the client. The message is not filtered or published to a channel.

    Parameters:
    from - The Client that published the message, or null if not known/available
    message -

    deliver

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

    setListener

    void setListener(Listener listener)
    Deprecated. use addListener(EventListener)


    getListener

    Listener getListener()
    Deprecated. Returns only the first listener added


    addListener

    void addListener(EventListener listener)

    removeListener

    void removeListener(EventListener 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.



    Copyright © 2013 Oracle Corporation. All Rights Reserved.