org.cometd.client
Class BayeuxClient

java.lang.Object
  extended by org.cometd.common.AbstractClientSession
      extended by org.cometd.client.BayeuxClient
All Implemented Interfaces:
Bayeux, ClientSession, Session, TransportListener

public class BayeuxClient
extends AbstractClientSession
implements Bayeux, ClientSession, TransportListener

When the client is started, a handshake is initialised and the call to start will block until either a successful handshake or all known servers have been tried.


Nested Class Summary
protected  class BayeuxClient.ClientSessionChannel
           
static class BayeuxClient.State
           
 
Nested classes/interfaces inherited from class org.cometd.common.AbstractClientSession
AbstractClientSession.AbstractSessionChannel, AbstractClientSession.Handler
 
Nested classes/interfaces inherited from interface org.cometd.bayeux.client.ClientSession
ClientSession.Extension
 
Field Summary
protected  java.util.concurrent.ScheduledExecutorService _scheduler
           
static java.lang.String BAYEUX_VERSION
           
 
Fields inherited from class org.cometd.common.AbstractClientSession
_attributes, _batch, _channels, _extensions, _idGen, _wild
 
Constructor Summary
BayeuxClient(org.eclipse.jetty.client.HttpClient httpClient, org.eclipse.jetty.client.Address address, java.lang.String uri)
          Deprecated.  
BayeuxClient(org.eclipse.jetty.client.HttpClient httpClient, org.eclipse.jetty.client.Address address, java.lang.String uri, java.util.Timer timer)
          Deprecated.  
BayeuxClient(org.eclipse.jetty.client.HttpClient httpClient, java.lang.String url)
           
BayeuxClient(java.lang.String url)
           
BayeuxClient(java.lang.String url, ClientTransport... transports)
           
BayeuxClient(java.lang.String url, org.eclipse.jetty.client.HttpClient httpClient)
           
BayeuxClient(java.lang.String url, java.util.concurrent.ScheduledExecutorService scheduler, ClientTransport... transports)
           
BayeuxClient(java.lang.String url, java.util.concurrent.ScheduledExecutorService scheduler, org.eclipse.jetty.client.HttpClient httpClient, ClientTransport... transports)
           
 
Method Summary
 void customize(org.eclipse.jetty.client.HttpExchange exchange)
          Customize an Exchange.
 void disconnect()
           
protected  void doDisconnected()
           
protected  void doSend(Message.Mutable message)
           
 java.util.List<java.lang.String> getAllowedTransports()
           
 org.cometd.client.BayeuxClient.ExpirableCookie getCookie(java.lang.String name)
           
 java.lang.String getId()
           
 java.util.Set<java.lang.String> getKnownTransportNames()
           
 java.lang.Object getOption(java.lang.String qualifiedName)
           
 java.util.Set<java.lang.String> getOptionNames()
           
 java.util.Map<java.lang.String,java.lang.Object> getOptions()
           
 Transport getTransport(java.lang.String transport)
           
 void handshake()
           
 BayeuxClient.State handshake(long waitMs)
           
 void handshake(java.util.Map<java.lang.String,java.lang.Object> template)
           
 BayeuxClient.State handshake(java.util.Map<java.lang.String,java.lang.Object> template, long waitMs)
           
 boolean isConnected()
           
protected  AbstractClientSession.AbstractSessionChannel newChannel(ChannelId channelId)
           
protected  ChannelId newChannelId(java.lang.String channelId)
           
protected  Message.Mutable newMessage()
           
 void onConnectException(java.lang.Throwable x)
           
 void onException(java.lang.Throwable x)
           
 void onExpire()
           
 void onMessages(java.util.List<Message.Mutable> messages)
           
 void onProtocolError(java.lang.String info)
           
protected  void processConnect(Message handshake)
           
protected  void processDisconnect(Message handshake)
           
protected  void processHandshake(Message handshake)
           
protected  void receive(java.util.List<Message.Mutable> incomingMessages)
           
protected  void send(Message.Mutable message)
           
protected  void sendBatch()
           
 void setCookie(java.lang.String name, java.lang.String value)
           
 void setCookie(java.lang.String name, java.lang.String value, int maxAge)
           
 void setOption(java.lang.String qualifiedName, java.lang.Object value)
           
 java.lang.String toString()
           
protected  void updateTransport(ClientTransport transport)
           
 boolean waitFor(long waitMs, BayeuxClient.State... states)
           
 
Methods inherited from class org.cometd.common.AbstractClientSession
addExtension, batch, endBatch, getAttribute, getAttributeNames, getChannel, receive, removeAttribute, setAttribute, startBatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.cometd.bayeux.client.ClientSession
addExtension, getChannel
 
Methods inherited from interface org.cometd.bayeux.Session
batch, endBatch, getAttribute, getAttributeNames, removeAttribute, setAttribute, startBatch
 

Field Detail

BAYEUX_VERSION

public static final java.lang.String BAYEUX_VERSION
See Also:
Constant Field Values

_scheduler

protected final java.util.concurrent.ScheduledExecutorService _scheduler
Constructor Detail

BayeuxClient

public BayeuxClient(org.eclipse.jetty.client.HttpClient httpClient,
                    org.eclipse.jetty.client.Address address,
                    java.lang.String uri)
Deprecated. 


BayeuxClient

public BayeuxClient(org.eclipse.jetty.client.HttpClient httpClient,
                    org.eclipse.jetty.client.Address address,
                    java.lang.String uri,
                    java.util.Timer timer)
Deprecated. 


BayeuxClient

public BayeuxClient(org.eclipse.jetty.client.HttpClient httpClient,
                    java.lang.String url)

BayeuxClient

public BayeuxClient(java.lang.String url)

BayeuxClient

public BayeuxClient(java.lang.String url,
                    ClientTransport... transports)

BayeuxClient

public BayeuxClient(java.lang.String url,
                    org.eclipse.jetty.client.HttpClient httpClient)

BayeuxClient

public BayeuxClient(java.lang.String url,
                    java.util.concurrent.ScheduledExecutorService scheduler,
                    ClientTransport... transports)

BayeuxClient

public BayeuxClient(java.lang.String url,
                    java.util.concurrent.ScheduledExecutorService scheduler,
                    org.eclipse.jetty.client.HttpClient httpClient,
                    ClientTransport... transports)
Method Detail

customize

public void customize(org.eclipse.jetty.client.HttpExchange exchange)
Customize an Exchange. Called when an exchange is about to be sent to allow Cookies and Credentials to be customized. Default implementation sets any cookies


disconnect

public void disconnect()
Specified by:
disconnect in interface Session
See Also:
Session.disconnect()

getAllowedTransports

public java.util.List<java.lang.String> getAllowedTransports()
Specified by:
getAllowedTransports in interface Bayeux

getCookie

public org.cometd.client.BayeuxClient.ExpirableCookie getCookie(java.lang.String name)

getId

public java.lang.String getId()
Specified by:
getId in interface Session

getKnownTransportNames

public java.util.Set<java.lang.String> getKnownTransportNames()
Specified by:
getKnownTransportNames in interface Bayeux

getOption

public java.lang.Object getOption(java.lang.String qualifiedName)
Specified by:
getOption in interface Bayeux
See Also:
Bayeux.getOption(java.lang.String)

getOptionNames

public java.util.Set<java.lang.String> getOptionNames()
Specified by:
getOptionNames in interface Bayeux
See Also:
Bayeux.getOptionNames()

getOptions

public java.util.Map<java.lang.String,java.lang.Object> getOptions()

getTransport

public Transport getTransport(java.lang.String transport)
Specified by:
getTransport in interface Bayeux

handshake

public void handshake()
Specified by:
handshake in interface ClientSession
See Also:
onConnectException(Throwable), onException(Throwable), onExpire()

handshake

public void handshake(java.util.Map<java.lang.String,java.lang.Object> template)
Specified by:
handshake in interface ClientSession
See Also:
onConnectException(Throwable), onException(Throwable), onExpire()

handshake

public BayeuxClient.State handshake(long waitMs)

handshake

public BayeuxClient.State handshake(java.util.Map<java.lang.String,java.lang.Object> template,
                                    long waitMs)

isConnected

public boolean isConnected()
Specified by:
isConnected in interface Session

setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value)

setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value,
                      int maxAge)

setOption

public void setOption(java.lang.String qualifiedName,
                      java.lang.Object value)
Specified by:
setOption in interface Bayeux
See Also:
Bayeux.setOption(java.lang.String, java.lang.Object)

doDisconnected

protected void doDisconnected()
Specified by:
doDisconnected in class AbstractClientSession
See Also:
AbstractClientSession.doDisconnected()

doSend

protected void doSend(Message.Mutable message)

newChannel

protected AbstractClientSession.AbstractSessionChannel newChannel(ChannelId channelId)
Specified by:
newChannel in class AbstractClientSession
See Also:
AbstractClientSession.newChannel(org.cometd.common.ChannelId)

newChannelId

protected ChannelId newChannelId(java.lang.String channelId)
Specified by:
newChannelId in class AbstractClientSession
See Also:
AbstractClientSession.newChannelId(java.lang.String)

newMessage

protected Message.Mutable newMessage()

processConnect

protected void processConnect(Message handshake)

processDisconnect

protected void processDisconnect(Message handshake)

processHandshake

protected void processHandshake(Message handshake)

receive

protected void receive(java.util.List<Message.Mutable> incomingMessages)

send

protected void send(Message.Mutable message)

sendBatch

protected void sendBatch()
Specified by:
sendBatch in class AbstractClientSession
See Also:
AbstractClientSession.sendBatch()

updateTransport

protected void updateTransport(ClientTransport transport)

waitFor

public boolean waitFor(long waitMs,
                       BayeuxClient.State... states)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

onConnectException

public void onConnectException(java.lang.Throwable x)
Specified by:
onConnectException in interface TransportListener

onException

public void onException(java.lang.Throwable x)
Specified by:
onException in interface TransportListener

onExpire

public void onExpire()
Specified by:
onExpire in interface TransportListener

onMessages

public void onMessages(java.util.List<Message.Mutable> messages)
Specified by:
onMessages in interface TransportListener

onProtocolError

public void onProtocolError(java.lang.String info)
Specified by:
onProtocolError in interface TransportListener


Copyright © 2010 Dojo Foundation. All Rights Reserved.