## org.mortbay.cometd
Class ClientImpl

    java.lang.Object
      org.mortbay.cometd.ClientImpl

All Implemented Interfaces:
  Client

Direct Known Subclasses:
  ContinuationClient

    public class ClientImpl

extends Object
implements Client

Author:
  gregw

Field Summary
`protected AbstractBayeux` `_bayeux`

Constructor Summary
`protected` `ClientImpl(AbstractBayeux bayeux)`
`protected` `ClientImpl(AbstractBayeux bayeux, String idPrefix)`
`protected` `ClientImpl(AbstractBayeux bayeux, String idPrefix, Listener listener)` Deprecated.

Method Summary
`void` `addListener(EventListener listener)`
`protected void` `addSubscription(ChannelImpl channel)`
`void` `deliver(Client from, Message message)` Deprecated. use `deliver(Client, String, Object, String)`
`void` `deliver(Client from, String toChannel, Object data, String id)`
`protected void` `doDelivery(Client from, Message message)`
`void` `endBatch()` End a batch of messages.
`boolean` `equals(Object o)`
`int` `getAdviceVersion()`
`String` `getBrowserId()`
`String` `getConnectionType()`
`String` `getId()`
`Listener` `getListener()`
`int` `getMessages()`
`long` `getTimeout()`
`boolean` `hasMessages()`
`boolean` `isJSONCommented()`
`boolean` `isLocal()`
`void` `publish(String toChannel, Object data, String msgId)` Deprecated. use `Channel#publish(Client, Object, String)`
`void` `remove(boolean timeout)`
`void` `removeListener(EventListener listener)`
`protected void` `removeSubscription(ChannelImpl channel)`
`int` `responded()`
`int` `responsePending()`
`void` `resume()` Called by deliver to resume anything waiting on this client.
`void` `setAdviceVersion(int version)`
`void` `setBrowserId(String id)`
`protected void` `setConnectionType(String type)`
`protected void` `setId(String _id)`
`void` `setJSONCommented(boolean commented)`
`void` `setListener(Listener listener)`
`void` `setTimeout(long timeoutMS)`
`void` `startBatch()` Start a batch of messages.
`void` `subscribe(String toChannel)` Deprecated. use `Channel#subscribe(Client)`
`Message` `takeMessage()`
`List<Message>` `takeMessages()` Take any messages queued for a client.
`String` `toString()`
`void` `unsubscribe(String toChannel)` Deprecated. use `Channel#unsubscribe(Client)`
`protected void` `unsubscribeAll()`

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

Field Detail

### _bayeux

    protected AbstractBayeux _bayeux

Constructor Detail

### ClientImpl

    protected ClientImpl(AbstractBayeux bayeux)

### ClientImpl

    protected ClientImpl(AbstractBayeux bayeux,
                         String idPrefix)

### ClientImpl

    protected ClientImpl(AbstractBayeux bayeux,
                         String idPrefix,
                         Listener listener)

  Deprecated.

Method Detail

### publish

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

  Deprecated. use `Channel#publish(Client, Object, String)`

  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.
  See Also:
    `Client.publish(java.lang.String, java.lang.Object, java.lang.String)`

### subscribe

    public void subscribe(String toChannel)

  Deprecated. use `Channel#subscribe(Client)`

  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`
  See Also:
    `Client.subscribe(java.lang.String)`

### unsubscribe

    public void unsubscribe(String toChannel)

  Deprecated. use `Channel#unsubscribe(Client)`

  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`
  See Also:
    `Client.unsubscribe(java.lang.String)`

### deliver

    public void deliver(Client from,
                        Message message)

  Deprecated. use `deliver(Client, String, Object, String)`

  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

### deliver

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

  Specified by:
    `deliver` in interface `Client`

### doDelivery

    protected void doDelivery(Client from,
                              Message message)

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

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

### getConnectionType

    public String getConnectionType()

### getId

    public String getId()

  Specified by:
    `getId` in interface `Client`

### hasMessages

    public boolean hasMessages()

  Specified by:
    `hasMessages` in interface `Client`

### isJSONCommented

    public boolean isJSONCommented()

  Returns:
    the commented

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

### remove

    public void remove(boolean timeout)

### responded

    public int responded()

### responsePending

    public int responsePending()

### resume

    public void resume()

  Called by deliver to resume anything waiting on this client.

### setJSONCommented

    public void setJSONCommented(boolean commented)

  Parameters:
    `commented` - the commented to set

### setListener

    public void setListener(Listener listener)

  Specified by:
    `setListener` in interface `Client`

### getListener

    public Listener getListener()

  Specified by:
    `getListener` in interface `Client`

### getMessages

    public int getMessages()

### takeMessages

    public List<Message> takeMessages()

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

  Specified by:
    `takeMessages` in interface `Client`

### takeMessage

    public Message takeMessage()

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### addSubscription

    protected void addSubscription(ChannelImpl channel)

### removeSubscription

    protected void removeSubscription(ChannelImpl channel)

### setConnectionType

    protected void setConnectionType(String type)

### setId

    protected void setId(String _id)

### unsubscribeAll

    protected void unsubscribeAll()

### setBrowserId

    public void setBrowserId(String id)

### getBrowserId

    public String getBrowserId()

### equals

    public boolean equals(Object o)

  Overrides:
    `equals` in class `Object`

### getAdviceVersion

    public int getAdviceVersion()

  Returns:
    the advised

### setAdviceVersion

    public void setAdviceVersion(int version)

  Parameters:
    `advised` - the advised to set

### addListener

    public void addListener(EventListener listener)

  Specified by:
    `addListener` in interface `Client`

### removeListener

    public void removeListener(EventListener listener)

  Specified by:
    `removeListener` in interface `Client`

### getTimeout

    public long getTimeout()

### setTimeout

    public void setTimeout(long timeoutMS)

Copyright © 2008 Mort Bay Consulting. All Rights Reserved.