Package tigase.xmpp

## Class XMPPIOService<RefObject>

- java.lang.Object
- - tigase.net.IOService<RefObject>
  - - tigase.xmpp.XMPPIOService<RefObject>

- Type Parameters:
    `RefObject` - is a reference object stored by this service. This is e reference to higher level data object keeping more information about the connection.
  All Implemented Interfaces:
    `java.util.concurrent.Callable<IOService<?>>`, `TLSEventHandler`, `IOListener`
  Direct Known Subclasses:
    `BoshIOService`, `C2SIOService`, `ComponentIOService`, `S2SIOService`, `WebSocketXMPPIOService`

      public class XMPPIOService<RefObject>
      extends IOService<RefObject>

  Describe class XMPPIOService here.
  Created: Tue Feb 7 07:15:02 2006
  Author:
    Artur Hefczyc

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.lang.String` | `ACK_NAME` |
    `static java.lang.String` | `CROSS_DOMAIN_POLICY_FILE_PROP_KEY` |
    `static java.lang.String` | `CROSS_DOMAIN_POLICY_FILE_PROP_VAL` |
    `static java.lang.String` | `DOM_HANDLER` | Key name of the system property for configuration protection from system overload and DOS attack.
    `static java.lang.String` | `ID_ATT` |
    `protected SimpleParser` | `parser` |
    `protected XMPPIOProcessor[]` | `processors` |
    `static java.lang.String` | `REQ_NAME` |
    `protected XMPPIOServiceListener` | `serviceListener` |
    `static java.lang.String` | `STREAM_CLOSING` |
    `java.util.concurrent.locks.ReentrantLock` | `writeInProgress` |

    - ### Fields inherited from class tigase.net.IOService

      `cb, CERT_CHECK_RESULT, CERT_REQUIRED_DOMAIN, decoder, encoder, HOSTNAME_KEY, LOCAL_CERT_CHECK_RESULT, partialCharacterBytes, PORT_TYPE_PROP_KEY, SESSION_ID_KEY, SSL_PROTOCOLS_KEY`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `XMPPIOService()` | Creates a new `XMPPIOService` instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addPacketToSend​(Packet packet)` | Method `addPacketToSend` adds new data which will be processed during next run.
    `protected void` | `addReceivedPacket​(Packet packet)` | Method `addReceivedPacket` puts processing results to queue.
    `IOService<?>` | `call()` |
    `boolean` | `checkBufferLimit​(int bufferSize)` |
    `boolean` | `checkData​(char[] data)` |
    `void` | `clearWaitingPackets()` | Clears queue of packets waiting to send.
    `void` | `forceStop()` |
    `java.util.Optional<JID>` | `getAuthorisedUserJid()` |
    `long` | `getLastXmppPacketReceiveTime()` | This method returns the time when the last XMPP packet was received, it is used to help detect dead connections.
    `long` | `getPacketsReceived​(boolean reset)` |
    `long` | `getPacketsSent​(boolean reset)` |
    `java.util.Queue<Packet>` | `getReceivedPackets()` |
    `long` | `getTotalPacketsReceived()` |
    `long` | `getTotalPacketsSent()` |
    `java.lang.String` | `getUserJid()` | Deprecated.
    `java.util.Map<java.lang.String,​Packet>` | `getWaitingForAct()` |
    `java.util.Queue<Packet>` | `getWaitingPackets()` | Returns queue with packets waiting to send.
    `java.lang.String` | `getXMLNS()` |
    `protected boolean` | `hasParsedElements()` |
    `protected void` | `moveParsedPacketsToReceived​(boolean sendAck)` |
    `protected java.lang.String` | `prepareStreamClose()` |
    `protected void` | `processSocketData()` |
    `void` | `processWaitingPackets()` |
    `protected int` | `receivedPackets()` |
    `void` | `setAckMode​(boolean white_char_ack, boolean xmpp_ack, boolean strict)` |
    `void` | `setAuthorisedUserJid​(JID authorisedUserJid)` |
    `void` | `setElementLimits​(int limit)` |
    `void` | `setIOServiceListener​(XMPPIOServiceListener servList)` |
    `void` | `setProcessors​(XMPPIOProcessor[] processors)` |
    `void` | `setUserJid​(java.lang.String jid)` | Deprecated.
    `void` | `setXMLNS​(java.lang.String xmlns)` |
    `protected boolean` | `shouldCountPacket​(Packet packet)` |
    `void` | `stop()` |
    `java.lang.String` | `toString()` |
    `void` | `writeRawData​(java.lang.String data)` |
    `protected void` | `xmppStreamClosed()` |
    `void` | `xmppStreamOpen​(java.lang.String data)` |
    `protected void` | `xmppStreamOpened​(java.util.Map<java.lang.String,​java.lang.String> attribs)` |

    - ### Methods inherited from class tigase.net.IOService

      `accept, byteOrder, connectionType, debug, debug, getBuffOverflow, getBytesReceived, getBytesSent, getCertificateContainer, getConnectionId, getDataReceiver, getIO, getLastTransferTime, getLocalAddress, getLocalCertificate, getLocalPort, getPeerCertificate, getReadCounters, getRefObject, getRemoteAddress, getSessionData, getSocketChannel, getSocketInputSize, getStatistics, getTlsUniqueId, getTotalBuffOverflow, getTotalBytesReceived, getTotalBytesSent, getUniqueId, getWriteCounters, handleMalformedInput, handshakeCompleted, isConnected, isInputBufferEmpty, isSocketServiceReady, readBytes, readCompleted, readData, setBufferLimit, setCertificateContainer, setConnectionId, setDataReceiver, setIOServiceListener, setRefObject, setSessionData, setSocketServiceReady, setSslContextContainer, setX509TrustManagers, startSSL, startTLS, startZLib, waitingToRead, waitingToSend, waitingToSendSize, writeBytes, writeData`

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

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

- - ### Field Detail

    - #### ACK_NAME

          public static final java.lang.String ACK_NAME

      See Also:
        Constant Field Values

    - #### CROSS_DOMAIN_POLICY_FILE_PROP_KEY

          public static final java.lang.String CROSS_DOMAIN_POLICY_FILE_PROP_KEY

      See Also:
        Constant Field Values

    - #### CROSS_DOMAIN_POLICY_FILE_PROP_VAL

          public static final java.lang.String CROSS_DOMAIN_POLICY_FILE_PROP_VAL

      See Also:
        Constant Field Values

    - #### DOM_HANDLER

          public static final java.lang.String DOM_HANDLER

      Key name of the system property for configuration protection from system overload and DOS attack.
      See Also:
        Constant Field Values

    - #### ID_ATT

          public static final java.lang.String ID_ATT

      See Also:
        Constant Field Values

    - #### REQ_NAME

          public static final java.lang.String REQ_NAME

      See Also:
        Constant Field Values

    - #### STREAM_CLOSING

          public static final java.lang.String STREAM_CLOSING

      See Also:
        Constant Field Values

    - #### writeInProgress

          public java.util.concurrent.locks.ReentrantLock writeInProgress

    - #### parser

          protected SimpleParser parser

    - #### processors

          protected XMPPIOProcessor[] processors

    - #### serviceListener

          protected XMPPIOServiceListener serviceListener

  - ### Constructor Detail

    - #### XMPPIOService

          public XMPPIOService()

      Creates a new `XMPPIOService` instance.

  - ### Method Detail

    - #### addPacketToSend

          public void addPacketToSend​(Packet packet)

      Method `addPacketToSend` adds new data which will be processed during next run. Data are kept in proper order like in FIFO queue.
      Parameters:
        `packet` - a `Packet` value of data to process.

    - #### call

          public IOService<?> call()
                            throws java.io.IOException

      Specified by:
        `call` in interface `java.util.concurrent.Callable<RefObject>`
      Overrides:
        `call` in class `IOService<RefObject>`
      Throws:
        `java.io.IOException`

    - #### checkBufferLimit

          public boolean checkBufferLimit​(int bufferSize)

      Specified by:
        `checkBufferLimit` in interface `IOListener`
      Overrides:
        `checkBufferLimit` in class `IOService<RefObject>`

    - #### checkData

          public boolean checkData​(char[] data)
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### clearWaitingPackets

          public void clearWaitingPackets()

      Clears queue of packets waiting to send. In case of connection close this packets may be sent to offline store but some processors may want stop this from happening - for that they may use this method

    - #### getWaitingPackets

          public java.util.Queue<Packet> getWaitingPackets()

      Returns queue with packets waiting to send. For use by ConnectionManager which may need to get undelivered packets

    - #### forceStop

          public void forceStop()

      Overrides:
        `forceStop` in class `IOService<RefObject>`

    - #### processWaitingPackets

          public void processWaitingPackets()
                                     throws java.io.IOException

      Specified by:
        `processWaitingPackets` in class `IOService<RefObject>`
      Throws:
        `java.io.IOException`

    - #### stop

          public void stop()

      Overrides:
        `stop` in class `IOService<RefObject>`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `IOService<RefObject>`

    - #### writeRawData

          public void writeRawData​(java.lang.String data)
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### xmppStreamOpen

          public void xmppStreamOpen​(java.lang.String data)

    - #### getPacketsReceived

          public long getPacketsReceived​(boolean reset)

    - #### getPacketsSent

          public long getPacketsSent​(boolean reset)

    - #### getReceivedPackets

          public java.util.Queue<Packet> getReceivedPackets()

    - #### getTotalPacketsReceived

          public long getTotalPacketsReceived()

    - #### getTotalPacketsSent

          public long getTotalPacketsSent()

    - #### getAuthorisedUserJid

          public java.util.Optional<JID> getAuthorisedUserJid()

    - #### setAuthorisedUserJid

          public void setAuthorisedUserJid​(JID authorisedUserJid)

    - #### getUserJid

          @Deprecated
          public java.lang.String getUserJid()

      Deprecated.

    - #### setUserJid

          @Deprecated
          public void setUserJid​(java.lang.String jid)

      Deprecated.

    - #### getWaitingForAct

          public java.util.Map<java.lang.String,​Packet> getWaitingForAct()

    - #### getXMLNS

          public java.lang.String getXMLNS()

    - #### setXMLNS

          public void setXMLNS​(java.lang.String xmlns)

    - #### setAckMode

          public void setAckMode​(boolean white_char_ack,
                                 boolean xmpp_ack,
                                 boolean strict)

    - #### setElementLimits

          public void setElementLimits​(int limit)

    - #### setIOServiceListener

          public void setIOServiceListener​(XMPPIOServiceListener servList)

    - #### setProcessors

          public void setProcessors​(XMPPIOProcessor[] processors)

    - #### getLastXmppPacketReceiveTime

          public long getLastXmppPacketReceiveTime()

      This method returns the time when the last XMPP packet was received, it is used to help detect dead connections.
      Returns:
        `long` number denoting time when the last XMPP packet was received.

    - #### addReceivedPacket

          protected void addReceivedPacket​(Packet packet)

      Method `addReceivedPacket` puts processing results to queue. The processing results are usually data (messages) which has been just received from socket.
      Parameters:
        `packet` - a `Packet` value of processing results.

    - #### shouldCountPacket

          protected boolean shouldCountPacket​(Packet packet)

    - #### prepareStreamClose

          protected java.lang.String prepareStreamClose()

    - #### processSocketData

          protected void processSocketData()
                                    throws java.io.IOException

      Specified by:
        `processSocketData` in class `IOService<RefObject>`
      Throws:
        `java.io.IOException`

    - #### receivedPackets

          protected int receivedPackets()

      Specified by:
        `receivedPackets` in class `IOService<RefObject>`

    - #### xmppStreamClosed

          protected void xmppStreamClosed()

    - #### xmppStreamOpened

          protected void xmppStreamOpened​(java.util.Map<java.lang.String,​java.lang.String> attribs)

    - #### hasParsedElements

          protected boolean hasParsedElements()

    - #### moveParsedPacketsToReceived

          protected void moveParsedPacketsToReceived​(boolean sendAck)