Package tigase.server.websocket

## Class WebSocketXMPPIOService<RefObject>

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

- All Implemented Interfaces:
    `java.util.concurrent.Callable<IOService<?>>`, `TLSEventHandler`, `IOListener`

      public class WebSocketXMPPIOService<RefObject>
      extends XMPPIOService<RefObject>

  Class implements basic support for WebSocket protocol. It extends XMPPIOService so it can be used instead of XMPPIOService in ClientConnectionManager to allow web clients to connect to it without using BOSH extension.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `WebSocketXMPPIOService.State` |
    `static class` | `WebSocketXMPPIOService.WebSocketXMPPSpec` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected long` | `frameLength` |
    `protected byte[]` | `maskingKey` |

    - ### Fields inherited from class tigase.xmpp.XMPPIOService

      `ACK_NAME, CROSS_DOMAIN_POLICY_FILE_PROP_KEY, CROSS_DOMAIN_POLICY_FILE_PROP_VAL, DOM_HANDLER, ID_ATT, parser, processors, REQ_NAME, serviceListener, STREAM_CLOSING, 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
    --- | ---
    `WebSocketXMPPIOService​(WebSocketProtocolIfc[] enabledProtocols)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `addReceivedPacket​(Packet packet)` | Method `addReceivedPacket` puts processing results to queue.
    `void` | `dumpHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)` |
    `protected WebSocketXMPPIOService.State` | `getState()` |
    `protected WebSocketXMPPIOService.WebSocketXMPPSpec` | `getWebSocketXMPPSpec()` |
    `protected int` | `parseHttpHeaders​(byte[] buf, java.util.Map<java.lang.String,​java.lang.String> headers)` |
    `protected java.lang.String` | `prepareStreamClose()` |
    `protected void` | `processSocketData()` |
    `protected char[]` | `readData()` |
    `protected void` | `setState​(WebSocketXMPPIOService.State state)` |
    `void` | `stop()` |
    `protected void` | `writeBytes​(java.nio.ByteBuffer data)` |
    `protected void` | `writeData​(java.lang.String data)` | Custom implementation of writeData function which encodes data in WebSocket protocol frames

    - ### Methods inherited from class tigase.xmpp.XMPPIOService

      `addPacketToSend, call, checkBufferLimit, checkData, clearWaitingPackets, forceStop, getAuthorisedUserJid, getLastXmppPacketReceiveTime, getPacketsReceived, getPacketsSent, getReceivedPackets, getTotalPacketsReceived, getTotalPacketsSent, getUserJid, getWaitingForAct, getWaitingPackets, getXMLNS, hasParsedElements, moveParsedPacketsToReceived, processWaitingPackets, receivedPackets, setAckMode, setAuthorisedUserJid, setElementLimits, setIOServiceListener, setProcessors, setUserJid, setXMLNS, shouldCountPacket, toString, writeRawData, xmppStreamClosed, xmppStreamOpen, xmppStreamOpened`

    - ### 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, setBufferLimit, setCertificateContainer, setConnectionId, setDataReceiver, setIOServiceListener, setRefObject, setSessionData, setSocketServiceReady, setSslContextContainer, setX509TrustManagers, startSSL, startTLS, startZLib, waitingToRead, waitingToSend, waitingToSendSize`

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

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

- - ### Field Detail

    - #### frameLength

          protected long frameLength

    - #### maskingKey

          protected byte[] maskingKey

  - ### Constructor Detail

    - #### WebSocketXMPPIOService

          public WebSocketXMPPIOService​(WebSocketProtocolIfc[] enabledProtocols)

  - ### Method Detail

    - #### stop

          public void stop()

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

    - #### dumpHeaders

          public void dumpHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)

    - #### getState

          protected WebSocketXMPPIOService.State getState()

    - #### setState

          protected void setState​(WebSocketXMPPIOService.State state)

    - #### addReceivedPacket

          protected void addReceivedPacket​(Packet packet)

      Description copied from class: `XMPPIOService`
      Method `addReceivedPacket` puts processing results to queue. The processing results are usually data (messages) which has been just received from socket.
      Overrides:
        `addReceivedPacket` in class `XMPPIOService<RefObject>`
      Parameters:
        `packet` - a `Packet` value of processing results.

    - #### processSocketData

          protected void processSocketData()
                                    throws java.io.IOException

      Overrides:
        `processSocketData` in class `XMPPIOService<RefObject>`
      Throws:
        `java.io.IOException`

    - #### getWebSocketXMPPSpec

          protected WebSocketXMPPIOService.WebSocketXMPPSpec getWebSocketXMPPSpec()

    - #### prepareStreamClose

          protected java.lang.String prepareStreamClose()

      Overrides:
        `prepareStreamClose` in class `XMPPIOService<RefObject>`

    - #### readData

          protected char[] readData()
                             throws java.io.IOException

      Overrides:
        `readData` in class `IOService<RefObject>`
      Throws:
        `java.io.IOException`

    - #### writeData

          protected void writeData​(java.lang.String data)

      Custom implementation of writeData function which encodes data in WebSocket protocol frames
      Overrides:
        `writeData` in class `IOService<RefObject>`

    - #### parseHttpHeaders

          protected int parseHttpHeaders​(byte[] buf,
                                         java.util.Map<java.lang.String,​java.lang.String> headers)

    - #### writeBytes

          protected void writeBytes​(java.nio.ByteBuffer data)

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