Package org.zkoss.zkmax.au.websocket

## Class WSAuWriter

- java.lang.Object
- - org.zkoss.zkmax.au.websocket.WSAuWriter

- All Implemented Interfaces:
    `AuWriter`

      public class WSAuWriter
      extends java.lang.Object
      implements AuWriter

  An AuWriter that is based on WebSocket.
  Since:
    8.5.0
  Author:
    wenninghsu

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `WSAuWriter()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close​(java.lang.Object websocketEndpoint, java.lang.Object response)` | Closes the writer and flush the result to client.
    `java.lang.Object` | `complete()` | Indicates the writing has been completed.
    `AuWriter` | `open​(java.lang.Object websocketEndpoint, java.lang.Object response)` | Initializes the writer.
    `void` | `resend​(java.lang.Object prevContent)` | Resend the content of the previous request returned by `AuWriter.complete()`.
    `protected byte[]` | `restore​(java.lang.Object data)` |
    `protected java.lang.Object` | `save​(byte[] data)` |
    `void` | `setCompress​(boolean compress)` | Sets whether to compress the output with GZIP.
    `void` | `write​(java.util.Collection<AuResponse> responses)` | Generates a list of responses to the output.
    `void` | `write​(AuResponse response)` | Generates the specified the response to the output.
    `void` | `writeResponseId​(int resId)` | Generates the response ID to the output.

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

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

- - ### Constructor Detail

    - #### WSAuWriter

          public WSAuWriter()

  - ### Method Detail

    - #### setCompress

          public void setCompress​(boolean compress)

      Description copied from interface: `AuWriter`
      Sets whether to compress the output with GZIP.

      Default: true.

      Specified by:
        `setCompress` in interface `AuWriter`

    - #### open

          public AuWriter open​(java.lang.Object websocketEndpoint,
                               java.lang.Object response)
                        throws java.io.IOException

      Description copied from interface: `AuWriter`
      Initializes the writer.
      Specified by:
        `open` in interface `AuWriter`
      Parameters:
        `websocketEndpoint` - the request (HttpServletRequest if HTTP)
        `response` - the response (HttpServletResponse if HTTP)
      Returns:
        this object
      Throws:
        `java.io.IOException`

    - #### close

          public void close​(java.lang.Object websocketEndpoint,
                            java.lang.Object response)
                     throws java.io.IOException

      Description copied from interface: `AuWriter`
      Closes the writer and flush the result to client.
      Specified by:
        `close` in interface `AuWriter`
      Parameters:
        `websocketEndpoint` - the request (HttpServletRequest if HTTP)
        `response` - the response (HttpServletResponse if HTTP)
      Throws:
        `java.io.IOException`

    - #### complete

          public java.lang.Object complete()
                                    throws java.io.IOException

      Description copied from interface: `AuWriter`
      Indicates the writing has been completed. Invokes this method before `AuWriter.close(java.lang.Object, java.lang.Object)`, if the caller supports the resend mechanism. The caller usually stores the return value to a desktop by `DesktopCtrl.responseSent(java.lang.String, java.lang.Object)`).

      Unlike `AuWriter.close(java.lang.Object, java.lang.Object)`, this method must be called in an activated execution.

      Once this method is called, the caller shall not invoke any other write method. It shall invoke only `AuWriter.close(java.lang.Object, java.lang.Object)` to end the writer.

      Specified by:
        `complete` in interface `AuWriter`
      Throws:
        `java.io.IOException`

    - #### resend

          public void resend​(java.lang.Object prevContent)
                      throws java.io.IOException

      Description copied from interface: `AuWriter`
      Resend the content of the previous request returned by `AuWriter.complete()`.

      The content is usually stored to a desktop by `DesktopCtrl.responseSent(java.lang.String, java.lang.Object)`, and retrieved by `DesktopCtrl.getLastResponse(java.lang.String)`.

      Once this method is called, the caller shall not invoke any other write method nor `AuWriter.complete()`. It shall invoke only `AuWriter.close(java.lang.Object, java.lang.Object)` to end the writer.

      Specified by:
        `resend` in interface `AuWriter`
      Parameters:
        `prevContent` - the previous content returned by `AuWriter.close(java.lang.Object, java.lang.Object)` of the previous `AuWriter`.
      Throws:
        `java.io.IOException`

    - #### writeResponseId

          public void writeResponseId​(int resId)
                               throws java.io.IOException

      Description copied from interface: `AuWriter`
      Generates the response ID to the output.
      Specified by:
        `writeResponseId` in interface `AuWriter`
      Throws:
        `java.io.IOException`
      See Also:
        `DesktopCtrl.getResponseId(boolean)`

    - #### write

          public void write​(AuResponse response)
                     throws java.io.IOException

      Description copied from interface: `AuWriter`
      Generates the specified the response to the output.
      Specified by:
        `write` in interface `AuWriter`
      Throws:
        `java.io.IOException`

    - #### write

          public void write​(java.util.Collection<AuResponse> responses)
                     throws java.io.IOException

      Description copied from interface: `AuWriter`
      Generates a list of responses to the output.
      Specified by:
        `write` in interface `AuWriter`
      Throws:
        `java.io.IOException`

    - #### restore

          protected byte[] restore​(java.lang.Object data)

    - #### save

          protected java.lang.Object save​(byte[] data)