パッケージ org.fanout.gripcontrol

クラス GripControl

java.lang.Object
org.fanout.gripcontrol.GripControl

public class GripControl
extends Object
This class and its features are used in conjunction with GRIP proxies. This includes facilitating the creation of hold instructions for HTTP long-polling and HTTP streaming, parsing GRIP URIs into config objects, validating the GRIP-SIG header coming from GRIP proxies, creating GRIP channel headers, and also WebSocket-over-HTTP features such as encoding/decoding web socket events and generating control messages.
  • コンストラクタの詳細

    • GripControl

      public GripControl()
  • メソッドの詳細

    • createHold

      public static String createHold​(String mode, List<Channel> channels, Response response, int timeout)
      Create GRIP hold instructions for the specified parameters including a timeout. To disable the timeout pass 0.
    • createHoldResponse

      public static String createHoldResponse​(List<Channel> channels)
      Create a GRIP hold response for HTTP long-polling. This method simply passes the specified parameters to the createHold method with "response" as the hold mode.
    • createHoldResponse

      public static String createHoldResponse​(List<Channel> channels, Response response)
      Create a GRIP hold response for HTTP long-polling. This method simply passes the specified parameters to the createHold method with "response" as the hold mode.
    • createHoldResponse

      public static String createHoldResponse​(List<Channel> channels, Response response, int timeout)
      Create a GRIP hold response for HTTP long-polling. This method simply passes the specified parameters to the createHold method with "response" as the hold mode.
    • createHoldStream

      public static String createHoldStream​(List<Channel> channels)
      Create a GRIP hold stream for HTTP streaming. This method simply passes the specified parameters to the createHold method with "response" as the hold mode.
    • createHoldStream

      public static String createHoldStream​(List<Channel> channels, Response response)
      Create a GRIP hold stream for HTTP streaming. This method simply passes the specified parameters to the createHold method with "response" as the hold mode.
    • createGripChannelHeader

      public static String createGripChannelHeader​(List<Channel> channels)
      Create a GRIP channel header for the specified channels. The returned GRIP channel header is used when sending instructions to GRIP proxies via HTTP headers.
    • webSocketControlMessage

      public static String webSocketControlMessage​(String type)
      Generate a WebSocket control message with the specified type and optional arguments. WebSocket control messages are passed to GRIP proxies and example usage includes subscribing/unsubscribing a WebSocket connection to/from a channel.
    • webSocketControlMessage

      public static String webSocketControlMessage​(String type, Map<String,​Object> args)
      Generate a WebSocket control message with the specified type and optional arguments. WebSocket control messages are passed to GRIP proxies and example usage includes subscribing/unsubscribing a WebSocket connection to/from a channel.
    • parseGripUri

      public static Map<String,​Object> parseGripUri​(String uri) throws UnsupportedEncodingException, MalformedURLException
      Parse the specified GRIP URI into a config object. The URI can include "iss" and "key" JWT authentication query parameters as well as any other required query string parameters. The JWT "key" query parameter can be provided as-is or in base64 encoded format.
      例外:
      UnsupportedEncodingException
      MalformedURLException
    • validateSig

      public static boolean validateSig​(String token, String key)
      Validate the specified JWT token and key. This method is used to validate the GRIP-SIG header coming from GRIP proxies such as Pushpin or Fanout.io. Note that the token expiration is also verified.
    • encodeWebSocketEvents

      public static String encodeWebSocketEvents​(List<WebSocketEvent> webSocketEvents)
      Encode the specified array of WebSocketEvent instances. The returned string value should then be passed to a GRIP proxy in the body of an HTTP response when using the WebSocket-over-HTTP protocol.
    • encodeWebSocketEventsBinary

      public static byte[] encodeWebSocketEventsBinary​(List<WebSocketEvent> webSocketEvents)
      Encode the specified array of WebSocketEvent instances as a byte array. The returned string value should then be passed to a GRIP proxy in the body of an HTTP response when using the WebSocket-over-HTTP protocol.
    • decodeWebSocketEvents

      public static List<WebSocketEvent> decodeWebSocketEvents​(String body)
      Decode the request body into an array of WebSocketEvent instances. A RuntimeError is raised if the format is invalid.
      パラメータ:
      body - a String representing the request body.
    • decodeWebSocketEvents

      public static List<WebSocketEvent> decodeWebSocketEvents​(byte[] bytes)
      Decode the request body into an array of WebSocketEvent instances. A RuntimeError is raised if the format is invalid.
      パラメータ:
      bytes - a byte array representing the request body. This is expected to be encoded as UTF-8