tigase.jaxmpp.core.client.connector
Class AbstractBoshConnector

java.lang.Object
  extended by tigase.jaxmpp.core.client.connector.AbstractBoshConnector
All Implemented Interfaces:
Connector

public abstract class AbstractBoshConnector
extends Object
implements Connector


Nested Class Summary
static class AbstractBoshConnector.BoshConnectorEvent
           
 
Nested classes/interfaces inherited from interface tigase.jaxmpp.core.client.Connector
Connector.ConnectorEvent, Connector.State
 
Field Summary
static String AUTHID_KEY
           
static String BOSH_SERVICE_URL
          Deprecated. use AbstractBoshConnector#BOSH_SERVICE_URL_KEY
static String BOSH_SERVICE_URL_KEY
           
protected  Logger log
           
protected  Observable observable
           
protected  Set<BoshRequest> requests
           
static String RID_KEY
           
protected  SessionObject sessionObject
           
static String SID_KEY
           
 
Fields inherited from interface tigase.jaxmpp.core.client.Connector
BodyReceived, Connected, CONNECTOR_STAGE_KEY, DISABLE_KEEPALIVE_KEY, ENCRYPTED_KEY, EncryptionEstablished, Error, EXTERNAL_KEEPALIVE_KEY, SEE_OTHER_HOST_KEY, StanzaReceived, StanzaSending, StateChanged, StreamTerminated, TRUST_MANAGERS_KEY
 
Constructor Summary
AbstractBoshConnector(Observable parentObservable, SessionObject sessionObject)
           
 
Method Summary
 void addListener(EventType eventType, Listener<? extends Connector.ConnectorEvent> listener)
          Adds a listener bound by the given event type.
protected  void addToRequests(BoshRequest worker)
           
protected  int countActiveRequests()
           
 XmppSessionLogic createSessionLogic(XmppModulesManager modulesManager, PacketWriter writer)
          Returns instance of XmppSessionLogic to work with this connector.
protected  void fireOnConnected(SessionObject sessionObject)
           
protected  void fireOnError(int responseCode, String responseData, Element response, Throwable caught, SessionObject sessionObject)
           
protected  void fireOnStanzaReceived(int responseCode, String responseData, Element response, SessionObject sessionObject)
           
protected  void fireOnTerminate(int responseCode, String responseData, Element response, SessionObject sessionObject)
           
 Observable getObservable()
          Returns observable
protected  String getSid()
           
 Connector.State getState()
           
 boolean isSecure()
           
 void keepalive()
          Whitespace ping.
protected  Long nextRid()
           
protected  void onError(BoshRequest request, int responseCode, String responseData, Element response, Throwable caught)
           
protected  void onResponse(BoshRequest request, int responseCode, String responseData, Element response)
           
protected  void onTerminate(BoshRequest request, int responseCode, String responseData, Element response)
           
protected  Element prepareBody(byte[] payload)
           
protected  Element prepareBody(Element payload)
           
protected  Element prepareRetartBody()
           
protected  Element prepareStartBody()
           
protected  Element prepareTerminateBody(Element payload)
           
protected abstract  void processSendData(Element element)
           
 void removeAllListeners()
           
protected  void removeFromRequests(BoshRequest ack)
           
 void removeListener(EventType eventType, Listener<Connector.ConnectorEvent> listener)
           
 void restartStream()
           
 void send(byte[] buffer)
           
 void send(Element stanza)
           
 void setObservable(Observable observable)
           
protected  void setSid(String sid)
           
protected  void setStage(Connector.State state)
           
 void start()
           
 void stop()
           
 void stop(boolean terminate)
           
protected  void terminateAllWorkers()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTHID_KEY

public static final String AUTHID_KEY
See Also:
Constant Field Values

BOSH_SERVICE_URL

@Deprecated
public static final String BOSH_SERVICE_URL
Deprecated. use AbstractBoshConnector#BOSH_SERVICE_URL_KEY
See Also:
Constant Field Values

BOSH_SERVICE_URL_KEY

public static final String BOSH_SERVICE_URL_KEY
See Also:
Constant Field Values

RID_KEY

public static final String RID_KEY
See Also:
Constant Field Values

SID_KEY

public static final String SID_KEY
See Also:
Constant Field Values

log

protected final Logger log

observable

protected Observable observable

requests

protected final Set<BoshRequest> requests

sessionObject

protected final SessionObject sessionObject
Constructor Detail

AbstractBoshConnector

public AbstractBoshConnector(Observable parentObservable,
                             SessionObject sessionObject)
Method Detail

addListener

public void addListener(EventType eventType,
                        Listener<? extends Connector.ConnectorEvent> listener)
Description copied from interface: Connector
Adds a listener bound by the given event type.

Specified by:
addListener in interface Connector
Parameters:
eventType - type of event
listener - the listener

addToRequests

protected void addToRequests(BoshRequest worker)

countActiveRequests

protected int countActiveRequests()

createSessionLogic

public XmppSessionLogic createSessionLogic(XmppModulesManager modulesManager,
                                           PacketWriter writer)
Description copied from interface: Connector
Returns instance of XmppSessionLogic to work with this connector.

Specified by:
createSessionLogic in interface Connector
Parameters:
modulesManager - module manager
writer - writer
Returns:
XmppSessionLogic

fireOnConnected

protected void fireOnConnected(SessionObject sessionObject)
                        throws JaxmppException
Throws:
JaxmppException

fireOnError

protected void fireOnError(int responseCode,
                           String responseData,
                           Element response,
                           Throwable caught,
                           SessionObject sessionObject)
                    throws JaxmppException
Throws:
JaxmppException

fireOnStanzaReceived

protected void fireOnStanzaReceived(int responseCode,
                                    String responseData,
                                    Element response,
                                    SessionObject sessionObject)
                             throws JaxmppException
Throws:
JaxmppException

fireOnTerminate

protected void fireOnTerminate(int responseCode,
                               String responseData,
                               Element response,
                               SessionObject sessionObject)
                        throws JaxmppException
Throws:
JaxmppException

getObservable

public Observable getObservable()
Description copied from interface: Connector
Returns observable

Specified by:
getObservable in interface Connector
Returns:

getSid

protected String getSid()

getState

public Connector.State getState()
Specified by:
getState in interface Connector

isSecure

public boolean isSecure()
Specified by:
isSecure in interface Connector

keepalive

public void keepalive()
               throws JaxmppException
Description copied from interface: Connector
Whitespace ping.

Specified by:
keepalive in interface Connector
Throws:
JaxmppException

nextRid

protected Long nextRid()

onError

protected void onError(BoshRequest request,
                       int responseCode,
                       String responseData,
                       Element response,
                       Throwable caught)
                throws JaxmppException
Throws:
JaxmppException

onResponse

protected void onResponse(BoshRequest request,
                          int responseCode,
                          String responseData,
                          Element response)
                   throws JaxmppException
Throws:
JaxmppException

onTerminate

protected void onTerminate(BoshRequest request,
                           int responseCode,
                           String responseData,
                           Element response)
                    throws JaxmppException
Throws:
JaxmppException

prepareBody

protected Element prepareBody(byte[] payload)
                       throws XMLException
Throws:
XMLException

prepareBody

protected Element prepareBody(Element payload)
                       throws XMLException
Throws:
XMLException

prepareRetartBody

protected Element prepareRetartBody()
                             throws XMLException
Throws:
XMLException

prepareStartBody

protected Element prepareStartBody()
                            throws XMLException
Throws:
XMLException

prepareTerminateBody

protected Element prepareTerminateBody(Element payload)
                                throws XMLException
Throws:
XMLException

processSendData

protected abstract void processSendData(Element element)
                                 throws XMLException,
                                        JaxmppException
Throws:
XMLException
JaxmppException

removeAllListeners

public void removeAllListeners()
Specified by:
removeAllListeners in interface Connector

removeFromRequests

protected void removeFromRequests(BoshRequest ack)

removeListener

public void removeListener(EventType eventType,
                           Listener<Connector.ConnectorEvent> listener)
Specified by:
removeListener in interface Connector

restartStream

public void restartStream()
                   throws XMLException,
                          JaxmppException
Specified by:
restartStream in interface Connector
Throws:
XMLException
JaxmppException

send

public void send(byte[] buffer)
          throws JaxmppException
Throws:
JaxmppException

send

public void send(Element stanza)
          throws XMLException,
                 JaxmppException
Specified by:
send in interface Connector
Throws:
XMLException
JaxmppException

setObservable

public void setObservable(Observable observable)
Specified by:
setObservable in interface Connector

setSid

protected void setSid(String sid)

setStage

protected void setStage(Connector.State state)
                 throws JaxmppException
Throws:
JaxmppException

start

public void start()
           throws XMLException,
                  JaxmppException
Specified by:
start in interface Connector
Throws:
XMLException
JaxmppException

stop

public void stop()
          throws XMLException,
                 JaxmppException
Specified by:
stop in interface Connector
Throws:
XMLException
JaxmppException

stop

public void stop(boolean terminate)
          throws XMLException,
                 JaxmppException
Specified by:
stop in interface Connector
Throws:
XMLException
JaxmppException

terminateAllWorkers

protected void terminateAllWorkers()


Copyright © 2006-2012 Tigase. All Rights Reserved.