Class ServerExitNotice

java.lang.Object
com.iizix.server.ServerExitNotice

public final class ServerExitNotice extends Object
What a connected client is told when the server exits (CC-SERVER-RESTART-UPDATE-V5, the owner's texts of the survey's section 8): the WebSocket close reason of the close code GCloseCodes.CC_SERVER_RESTART, "iz!4006!text", one text for a Browser and one for iiziRun on Cordova, where a page cannot be reloaded and the app is restarted instead. A close reason is at most 123 bytes of UTF-8, so every text here stays under 115 bytes with the 8-byte prefix;
invalid reference
ServerExitNoticeTest
measures it.

A client of this release shows its own localized text for the code and keeps the server's text for a client that has none (an old cached page shows "WebSocket error 4006" and the text).

Author:
Christopher Mindus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The longest close reason the WebSocket protocol carries, in bytes of UTF-8.
    static final String
    The prefix of the reason: the close code for a client whose Browser drops the code.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    bytes(String reason)
    Measures a close reason.
    static String
    closeReason(int code, boolean iiziRun)
    Gets the close reason a client is sent: the prefix and the text.
    static String
    text(int code, boolean iiziRun)
    Gets the text a client is told for a server exit.
  • Field Details

    • MAX_REASON_BYTES

      public static final int MAX_REASON_BYTES
      The longest close reason the WebSocket protocol carries, in bytes of UTF-8.
      See Also:
    • PREFIX

      public static final String PREFIX
      The prefix of the reason: the close code for a client whose Browser drops the code.
      See Also:
  • Method Details

    • text

      public static String text(int code, boolean iiziRun)
      Gets the text a client is told for a server exit.
      Parameters:
      code - The exit code of the server: ServerExit.RESTART, ServerExit.UPDATE_RESTART or ServerExit.STOP.
      iiziRun - true for iiziRun on Cordova, false for a Browser.
      Returns:
      The English text, without the prefix.
    • closeReason

      public static String closeReason(int code, boolean iiziRun)
      Gets the close reason a client is sent: the prefix and the text.
      Parameters:
      code - The exit code of the server.
      iiziRun - true for iiziRun on Cordova, false for a Browser.
      Returns:
      The reason, at most MAX_REASON_BYTES bytes of UTF-8.
    • bytes

      public static int bytes(String reason)
      Measures a close reason.
      Parameters:
      reason - The reason.
      Returns:
      Its length in bytes of UTF-8.