tigase.jaxmpp.j2se.connectors.socket

## Class SocketConnector

- java.lang.Object
- - tigase.jaxmpp.j2se.connectors.socket.SocketConnector

- All Implemented Interfaces:
    Connector

      public class SocketConnector
      extends Object
      implements Connector

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SocketConnector.DnsResolver`
    `static class` | `SocketConnector.Entry`
    `static interface` | `SocketConnector.HostChangedHandler` see-other-host

    - ### Nested classes/interfaces inherited from interface tigase.jaxmpp.core.client.Connector

      `Connector.ConnectedHandler, Connector.DisconnectedHandler, Connector.EncryptionEstablishedHandler, Connector.ErrorHandler, Connector.StanzaReceivedHandler, Connector.StanzaSendingHandler, Connector.State, Connector.StateChangedHandler, Connector.StreamTerminatedHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `COMPRESSION_DISABLED_KEY`
    `static HostnameVerifier` | `DEFAULT_HOSTNAME_VERIFIER`
    `static int` | `DEFAULT_SOCKET_BUFFER_SIZE` Default size of buffer used to decode data before parsing
    `static int` | `DEFAULT_SOCKET_TIMEOUT` Socket timeout.
    `static String` | `HOSTNAME_VERIFIER_DISABLED_KEY`
    `static String` | `HOSTNAME_VERIFIER_KEY`
    `static String` | `KEEP_ALIVE_DELAY_KEY`
    `static String` | `KEY_MANAGERS_KEY`
    `static String` | `PLAIN_SOCKET_TIMEOUT_KEY` Property to specify custom socket timeout for Plain Socket.
    `static String` | `SASL_EXTERNAL_ENABLED_KEY`
    `static String` | `SERVER_HOST`
    `static String` | `SERVER_PORT`
    `static String` | `SSL_SOCKET_FACTORY_KEY`
    `static String` | `SSL_SOCKET_TIMEOUT_KEY` Property to specify custom `socket timeout` for SSL Socket.
    `static String` | `TLS_DISABLED_KEY`

    - ### Fields inherited from interface tigase.jaxmpp.core.client.Connector

      `COMPRESSED_KEY, CONNECTOR_STAGE_KEY, CONNECTOR_STAGE_TIMESTAMP_KEY, DISABLE_KEEPALIVE_KEY, ENCRYPTED_KEY, EXTERNAL_KEEPALIVE_KEY, PROXY_HOST, PROXY_PORT, PROXY_TYPE, RECONNECTING_KEY, SEE_OTHER_HOST_KEY, TRUST_MANAGERS_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SocketConnector(Context context)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `XmppSessionLogic` | `createSessionLogic(XmppModulesManager modulesManager, PacketWriter writer)` Returns instance of XmppSessionLogic to work with this connector.
    `protected void` | `fireOnConnected(SessionObject sessionObject)`
    `protected void` | `fireOnError(Element response, Throwable caught, SessionObject sessionObject)`
    `protected void` | `fireOnStanzaReceived(StreamPacket response, SessionObject sessionObject)`
    `protected void` | `fireOnTerminate(SessionObject sessionObject)`
    `protected KeyManager[]` | `getKeyManagers()`
    `Connector.State` | `getState()` Returns current State of connector.
    `protected Integer` | `getTimeout(String propertyName, int defaultValue)` Returns timeout value.
    `boolean` | `isCompressed()` Returns true when stream is compressed
    `boolean` | `isSecure()` Returns connection security state.
    `static boolean` | `isTLSAvailable(SessionObject sessionObject)`
    `static boolean` | `isZLibAvailable(SessionObject sessionObject)` Returns true if server send stream features in which it advertises support for stream compression using ZLIB
    `void` | `keepalive()` Whitespace ping.
    `protected void` | `onError(Element response, Throwable caught)`
    `protected void` | `onErrorInThread(Exception e)`
    `protected void` | `onResponse(Element response)`
    `protected void` | `onStreamStart(Map<String,String> attribs)`
    `protected void` | `onStreamTerminate()`
    `void` | `onTLSStanza(Element elem)`
    `void` | `onZLibStanza(Element elem)` Handles result of requesting stream compression
    `protected void` | `proceedTLS()`
    `protected void` | `proceedZLib()` Method activates stream compression by replacing reader and writer fields values and restarting XMPP stream
    `void` | `processElement(Element elem)`
    `void` | `restartStream()` Sends new XML Stream header.
    `void` | `send(byte[] buffer)`
    `void` | `send(Element stanza)` Sends given XML Element to server.
    `protected void` | `setStage(Connector.State state)`
    `void` | `start()` Starts connector.
    `void` | `startTLS()`
    `void` | `startZLib()` Sends stanza to start stream compression using ZLIB
    `void` | `stop()` Stops connector and closes connections.
    `void` | `stop(boolean terminate)` Deprecated.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### COMPRESSION_DISABLED_KEY

          public static final String COMPRESSION_DISABLED_KEY

      See Also:
        Constant Field Values

    - #### DEFAULT_HOSTNAME_VERIFIER

          public static final HostnameVerifier DEFAULT_HOSTNAME_VERIFIER

    - #### DEFAULT_SOCKET_BUFFER_SIZE

          public static final int DEFAULT_SOCKET_BUFFER_SIZE

      Default size of buffer used to decode data before parsing
      See Also:
        Constant Field Values

    - #### HOSTNAME_VERIFIER_DISABLED_KEY

          public static final String HOSTNAME_VERIFIER_DISABLED_KEY

      See Also:
        Constant Field Values

    - #### HOSTNAME_VERIFIER_KEY

          public static final String HOSTNAME_VERIFIER_KEY

      See Also:
        Constant Field Values

    - #### KEY_MANAGERS_KEY

          public static final String KEY_MANAGERS_KEY

      See Also:
        Constant Field Values

    - #### SASL_EXTERNAL_ENABLED_KEY

          public static final String SASL_EXTERNAL_ENABLED_KEY

      See Also:
        Constant Field Values

    - #### SERVER_HOST

          public static final String SERVER_HOST

      See Also:
        Constant Field Values

    - #### SERVER_PORT

          public static final String SERVER_PORT

      See Also:
        Constant Field Values

    - #### DEFAULT_SOCKET_TIMEOUT

          public static final int DEFAULT_SOCKET_TIMEOUT

      Socket timeout.
      See Also:
        Constant Field Values

    - #### SSL_SOCKET_FACTORY_KEY

          public static final String SSL_SOCKET_FACTORY_KEY

      See Also:
        Constant Field Values

    - #### TLS_DISABLED_KEY

          public static final String TLS_DISABLED_KEY

      See Also:
        Constant Field Values

    - #### SSL_SOCKET_TIMEOUT_KEY

          public static final String SSL_SOCKET_TIMEOUT_KEY

      Property to specify custom `socket timeout` for SSL Socket. Default is `0`.
      See Also:
        Constant Field Values

    - #### PLAIN_SOCKET_TIMEOUT_KEY

          public static final String PLAIN_SOCKET_TIMEOUT_KEY

      Property to specify custom socket timeout for Plain Socket. Default is `180000 ms`.
      See Also:
        Constant Field Values

    - #### KEEP_ALIVE_DELAY_KEY

          public static final String KEEP_ALIVE_DELAY_KEY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SocketConnector

          public SocketConnector(Context context)

  - ### Method Detail

    - #### isTLSAvailable

          public static boolean isTLSAvailable(SessionObject sessionObject)
                                        throws XMLException

      Throws:
        `XMLException`

    - #### isZLibAvailable

          public static boolean isZLibAvailable(SessionObject sessionObject)
                                         throws XMLException

      Returns true if server send stream features in which it advertises support for stream compression using ZLIB
      Parameters:
        `sessionObject` -
      Returns:
      Throws:
        `XMLException`

    - #### 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(Element response,
                                     Throwable caught,
                                     SessionObject sessionObject)
                              throws JaxmppException

      Throws:
        `JaxmppException`

    - #### fireOnStanzaReceived

          protected void fireOnStanzaReceived(StreamPacket response,
                                              SessionObject sessionObject)
                                       throws JaxmppException

      Throws:
        `JaxmppException`

    - #### fireOnTerminate

          protected void fireOnTerminate(SessionObject sessionObject)
                                  throws JaxmppException

      Throws:
        `JaxmppException`

    - #### getKeyManagers

          protected KeyManager[] getKeyManagers()
                                         throws NoSuchAlgorithmException

      Throws:
        `NoSuchAlgorithmException`

    - #### getState

          public Connector.State getState()

      Returns current State of connector.
      Specified by:
        `getState` in interface `Connector`
      Returns:
        State of connector.

    - #### getTimeout

          protected Integer getTimeout(String propertyName,
                                       int defaultValue)

      Returns timeout value.
      Parameters:
        `propertyName` - name of property
        `defaultValue` - default value if property is `null`.
      Returns:
        timeout value or `null` if value is less than 0.

    - #### isCompressed

          public boolean isCompressed()

      Returns true when stream is compressed
      Specified by:
        `isCompressed` in interface `Connector`
      Returns:

    - #### isSecure

          public boolean isSecure()

      Description copied from interface: `Connector`
      Returns connection security state.
      Specified by:
        `isSecure` in interface `Connector`
      Returns:
        `true> if connection is secured and encrypted.`

    - #### keepalive

          public void keepalive()
                         throws JaxmppException

      Description copied from interface: `Connector`
      Whitespace ping.
      Specified by:
        `keepalive` in interface `Connector`
      Throws:
        `JaxmppException`

    - #### onError

          protected void onError(Element response,
                                 Throwable caught)
                          throws JaxmppException

      Throws:
        `JaxmppException`

    - #### onErrorInThread

          protected void onErrorInThread(Exception e)
                                  throws JaxmppException

      Throws:
        `JaxmppException`

    - #### onResponse

          protected void onResponse(Element response)
                             throws JaxmppException

      Throws:
        `JaxmppException`

    - #### onStreamStart

          protected void onStreamStart(Map<String,String> attribs)

    - #### onStreamTerminate

          protected void onStreamTerminate()
                                    throws JaxmppException

      Throws:
        `JaxmppException`

    - #### onTLSStanza

          public void onTLSStanza(Element elem)
                           throws JaxmppException

      Throws:
        `JaxmppException`

    - #### onZLibStanza

          public void onZLibStanza(Element elem)
                            throws JaxmppException

      Handles result of requesting stream compression
      Parameters:
        `elem` -
      Throws:
        `JaxmppException`

    - #### proceedTLS

          protected void proceedTLS()
                             throws JaxmppException

      Throws:
        `JaxmppException`

    - #### proceedZLib

          protected void proceedZLib()
                              throws JaxmppException

      Method activates stream compression by replacing reader and writer fields values and restarting XMPP stream
      Throws:
        `JaxmppException`

    - #### processElement

          public void processElement(Element elem)
                              throws JaxmppException

      Throws:
        `JaxmppException`

    - #### restartStream

          public void restartStream()
                             throws JaxmppException

      Description copied from interface: `Connector`
      Sends new XML Stream header.
      Specified by:
        `restartStream` in interface `Connector`
      Throws:
        `JaxmppException`

    - #### send

          public void send(byte[] buffer)
                    throws JaxmppException

      Throws:
        `JaxmppException`

    - #### send

          public void send(Element stanza)
                    throws JaxmppException

      Description copied from interface: `Connector`
      Sends given XML Element to server.
      Specified by:
        `send` in interface `Connector`
      Parameters:
        `stanza` - XML element to send.
      Throws:
        `JaxmppException`

    - #### setStage

          protected void setStage(Connector.State state)
                           throws JaxmppException

      Throws:
        `JaxmppException`

    - #### start

          public void start()
                     throws JaxmppException

      Description copied from interface: `Connector`
      Starts connector. If connector is properly configured it will tries to establsh connection with server.
      Specified by:
        `start` in interface `Connector`
      Throws:
        `JaxmppException`

    - #### startTLS

          public void startTLS()
                        throws JaxmppException

      Throws:
        `JaxmppException`

    - #### startZLib

          public void startZLib()
                         throws JaxmppException

      Sends stanza to start stream compression using ZLIB
      Throws:
        `JaxmppException`

    - #### stop

          public void stop()
                    throws JaxmppException

      Description copied from interface: `Connector`
      Stops connector and closes connections.
      Specified by:
        `stop` in interface `Connector`
      Throws:
        `JaxmppException`

    - #### stop

          @Deprecated
          public void stop(boolean terminate)
                                throws JaxmppException

      Deprecated.
      Description copied from interface: `Connector`
      Stops connector.
      Specified by:
        `stop` in interface `Connector`
      Parameters:
        `terminate` - if `true`then connection will be terminated immediatelly and connector will be stopped.``
      Throws:
        `JaxmppException`

Copyright © 2006–2016 Tigase. All rights reserved.