## org.mortbay.cometd.client
Class BayeuxClient

    java.lang.Object
      org.mortbay.cometd.client.BayeuxClient

All Implemented Interfaces:
  Client

    public class BayeuxClient

extends Object
implements Client

Constructor Summary
`BayeuxClient(HttpClient client, InetSocketAddress address, String uri)`

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` `getClientId()`
`String` `getId()`
`Listener` `getListener()`
`boolean` `hasMessages()`
`boolean` `isLocal()`
`boolean` `isPolling()`
`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` `start()`
`void` `startBatch()` Start a batch of messages.
`void` `subscribe(String toChannel)` Subscribe this client to a channel.
`List<Map<String,Object>>` `takeMessages()` Take any messages queued for a client.
`void` `unsubscribe(String toChannel)` Unsubscribe this client from a channel.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BayeuxClient

    public BayeuxClient(HttpClient client,
                        InetSocketAddress address,
                        String uri)
                 throws IOException

Throws:
  `IOException`

Method Detail

### getClientId

    public String getClientId()

### start

    public void start()

### isPolling

    public boolean isPolling()

### deliver

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

  Description copied from interface: `Client`
  Deliver a message to this client only Deliver a message directly to the client. The message is not filtered or published to a channel.

  Specified by:
    `deliver` in interface `Client`
  Parameters:
    `from` - The Client that published the message, or null if not known/available

### getId

    public String getId()

  Specified by:
    `getId` in interface `Client`

### getListener

    public Listener getListener()

  Specified by:
    `getListener` in interface `Client`

### hasMessages

    public boolean hasMessages()

  Specified by:
    `hasMessages` in interface `Client`

### isLocal

    public boolean isLocal()

  Specified by:
    `isLocal` in interface `Client`
  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.

### publish

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

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

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

### subscribe

    public void subscribe(String toChannel)

  Description copied from interface: `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).

  Specified by:
    `subscribe` in interface `Client`

### unsubscribe

    public void unsubscribe(String toChannel)

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

  Specified by:
    `unsubscribe` in interface `Client`

### remove

    public void remove(boolean timeout)

  Description copied from interface: `Client`
  Remove Client Unsubscribe client from all channels and remove it.

  Specified by:
    `remove` in interface `Client`

### setListener

    public void setListener(Listener listener)

  Specified by:
    `setListener` in interface `Client`

### takeMessages

    public List<Map<String,Object>> takeMessages()

  Description copied from interface: `Client`
  Take any messages queued for a client.

  Specified by:
    `takeMessages` in interface `Client`

### endBatch

    public void endBatch()

  Description copied from interface: `Client`
  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.

  Specified by:
    `endBatch` in interface `Client`

### startBatch

    public void startBatch()

  Description copied from interface: `Client`
  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.

  Specified by:
    `startBatch` in interface `Client`

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.