org.mortbay.cometd
Class ClientImpl

java.lang.Object
  extended by org.mortbay.cometd.ClientImpl
All Implemented Interfaces:
org.cometd.Client
Direct Known Subclasses:
ContinuationClient

public class ClientImpl
extends Object
implements org.cometd.Client

Author:
gregw

Field Summary
protected  AbstractBayeux _bayeux
           
 
Constructor Summary
protected ClientImpl(AbstractBayeux bayeux)
           
protected ClientImpl(AbstractBayeux bayeux, String idPrefix)
           
 
Method Summary
 void addExtension(org.cometd.Extension ext)
           
 void addListener(org.cometd.ClientListener listener)
           
protected  void addSubscription(ChannelImpl channel)
           
 void deliver(org.cometd.Client from, String toChannel, Object data, String id)
           
 void deliverLazy(org.cometd.Client from, String toChannel, Object data, String id)
           
 void disconnect()
           
 void doDeliverListeners()
           
protected  void doDelivery(org.cometd.Client from, org.cometd.Message msg)
           
 void endBatch()
           
 boolean equals(Object o)
           
 JSON.Literal getAdvice()
          Get the advice specific for this Client
 String getBrowserId()
           
 String getConnectionType()
           
 String getId()
           
 long getInterval()
           
 int getLag()
           
 int getMaxQueue()
           
 int getMessages()
           
 Queue<org.cometd.Message> getQueue()
           
 org.cometd.Channel[] getSubscriptions()
          Get the subscribed to channels
 long getTimeout()
           
 boolean hasMessages()
           
 boolean hasNonLazyMessages()
           
 boolean isExpired()
           
 boolean isLocal()
           
 boolean isMetaConnectDeliveryOnly()
           
 void lazyResume()
          Called by deliver to resume anything waiting on this client lazily
 void remove(boolean timeout)
           
 void removeListener(org.cometd.ClientListener listener)
           
protected  void removeSubscription(ChannelImpl channel)
           
 int responded()
           
 int responsePending()
           
 void resume()
          Called by deliver to resume anything waiting on this client.
 void returnMessages(List<org.cometd.Message> messages)
           
 void setAdvice(JSON.Literal advice)
           
 void setBrowserId(String id)
           
protected  void setConnectionType(String type)
           
protected  void setId(String id)
           
 void setInterval(long intervalMS)
          Set per client interval
 void setLag(int lag)
           
 void setMaxQueue(int maxQueue)
           
 void setMetaConnectDeliveryOnly(boolean deliverViaMetaConnectOnly)
           
 void setTimeout(long timeoutMS)
          Set per client timeout
 void startBatch()
           
 List<org.cometd.Message> takeMessages()
           
 String toString()
           
 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)
Method Detail

addExtension

public void addExtension(org.cometd.Extension ext)
Specified by:
addExtension in interface org.cometd.Client

deliver

public void deliver(org.cometd.Client from,
                    String toChannel,
                    Object data,
                    String id)
Specified by:
deliver in interface org.cometd.Client

deliverLazy

public void deliverLazy(org.cometd.Client from,
                        String toChannel,
                        Object data,
                        String id)

doDelivery

protected void doDelivery(org.cometd.Client from,
                          org.cometd.Message msg)

doDeliverListeners

public void doDeliverListeners()

setMetaConnectDeliveryOnly

public void setMetaConnectDeliveryOnly(boolean deliverViaMetaConnectOnly)

isMetaConnectDeliveryOnly

public boolean isMetaConnectDeliveryOnly()

startBatch

public void startBatch()
Specified by:
startBatch in interface org.cometd.Client

endBatch

public void endBatch()
Specified by:
endBatch in interface org.cometd.Client

getConnectionType

public String getConnectionType()

getId

public String getId()
Specified by:
getId in interface org.cometd.Client

hasMessages

public boolean hasMessages()
Specified by:
hasMessages in interface org.cometd.Client

hasNonLazyMessages

public boolean hasNonLazyMessages()

isLocal

public boolean isLocal()
Specified by:
isLocal in interface org.cometd.Client

disconnect

public void disconnect()
Specified by:
disconnect in interface org.cometd.Client

remove

public void remove(boolean timeout)

isExpired

public boolean isExpired()

responded

public int responded()

responsePending

public int responsePending()

lazyResume

public void lazyResume()
Called by deliver to resume anything waiting on this client lazily


resume

public void resume()
Called by deliver to resume anything waiting on this client.


getMessages

public int getMessages()

takeMessages

public List<org.cometd.Message> takeMessages()
Specified by:
takeMessages in interface org.cometd.Client

returnMessages

public void returnMessages(List<org.cometd.Message> messages)

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

public void unsubscribeAll()

setBrowserId

public void setBrowserId(String id)

getBrowserId

public String getBrowserId()

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getAdvice

public JSON.Literal getAdvice()
Get the advice specific for this Client

Returns:
advice specific for this client or null

setAdvice

public void setAdvice(JSON.Literal advice)
Parameters:
advice - specific for this client

addListener

public void addListener(org.cometd.ClientListener listener)
Specified by:
addListener in interface org.cometd.Client

removeListener

public void removeListener(org.cometd.ClientListener listener)
Specified by:
removeListener in interface org.cometd.Client

getInterval

public long getInterval()

setInterval

public void setInterval(long intervalMS)
Set per client interval

Parameters:
intervalMS - timeout in MS for longpoll duration or 0 to use default from AbstractBayeux.getMaxInterval().

getTimeout

public long getTimeout()

setTimeout

public void setTimeout(long timeoutMS)
Set per client timeout

Parameters:
timeoutMS - timeout in MS for longpoll duration or 0 to use default from AbstractBayeux.getTimeout().

setMaxQueue

public void setMaxQueue(int maxQueue)
Specified by:
setMaxQueue in interface org.cometd.Client

getMaxQueue

public int getMaxQueue()
Specified by:
getMaxQueue in interface org.cometd.Client

getQueue

public Queue<org.cometd.Message> getQueue()
Specified by:
getQueue in interface org.cometd.Client

getLag

public int getLag()
Returns:
The lag in ms as measured by an extension like the TimesyncExtension
See Also:
TimesyncExtension

setLag

public void setLag(int lag)
Parameters:
lag - in ms
See Also:
TimesyncExtension

getSubscriptions

public org.cometd.Channel[] getSubscriptions()
Get the subscribed to channels

Returns:
A copied array of the channels to which this client is subscribed


Copyright © 1995-2009 Mort Bay Consulting. All Rights Reserved.