Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## dojox.cometd
Interface Client

All Known Implementing Classes:
  BayeuxClient, ClientImpl

    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` | `deliver(Client from, Map<String,Object> message)` Deliver a message to this client only Deliver a message directly to the client.
`void` | `endBatch()` End a batch of messages.
`String` | `getId()`
`Listener` | `getListener()`
`boolean` | `hasMessages()`
`boolean` | `isLocal()`
`void` | `publish(String toChannel, Object data, String msgId)` Publish data from this client.
`void` | `remove(boolean timeout)` Remove Client Unsubscribe client from all channels and remove it.
`void` | `setListener(Listener listener)`
`void` | `startBatch()` Start a batch of messages.
`void` | `subscribe(String toChannel)` Subscribe this client to a channel.
`Queue<Map<String,Object>>` | `takeMessages()` Take any messages queued for a client.
`void` | `unsubscribe(String toChannel)` Unsubscribe this client from a channel.

Method Detail

### getId

    String getId()

### publish

    void publish(String toChannel,
                 Object data,
                 String msgId)

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

  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)

  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)

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

  Parameters:
    `toChannel` -

### remove

    void remove(boolean timeout)

  Remove Client Unsubscribe client from all channels and remove it.

  Parameters:
    `timeout` -

### hasMessages

    boolean hasMessages()

### takeMessages

    Queue<Map<String,Object>> takeMessages()

  Take any messages queued for a client.

### deliver

    void deliver(Client from,
                 Map<String,Object> message)

  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` -

### setListener

    void setListener(Listener listener)

### getListener

    Listener getListener()

### 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.