パッケージ 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() -
メソッドの概要
修飾子とタイプ メソッド 説明 static StringcreateGripChannelHeader(List<Channel> channels)Create a GRIP channel header for the specified channels.static StringcreateHold(String mode, List<Channel> channels, Response response, int timeout)Create GRIP hold instructions for the specified parameters including a timeout.static StringcreateHoldResponse(List<Channel> channels)Create a GRIP hold response for HTTP long-polling.static StringcreateHoldResponse(List<Channel> channels, Response response)Create a GRIP hold response for HTTP long-polling.static StringcreateHoldResponse(List<Channel> channels, Response response, int timeout)Create a GRIP hold response for HTTP long-polling.static StringcreateHoldStream(List<Channel> channels)Create a GRIP hold stream for HTTP streaming.static StringcreateHoldStream(List<Channel> channels, Response response)Create a GRIP hold stream for HTTP streaming.static List<WebSocketEvent>decodeWebSocketEvents(byte[] bytes)Decode the request body into an array of WebSocketEvent instances.static List<WebSocketEvent>decodeWebSocketEvents(String body)Decode the request body into an array of WebSocketEvent instances.static StringencodeWebSocketEvents(List<WebSocketEvent> webSocketEvents)Encode the specified array of WebSocketEvent instances.static byte[]encodeWebSocketEventsBinary(List<WebSocketEvent> webSocketEvents)Encode the specified array of WebSocketEvent instances as a byte array.static Map<String,Object>parseGripUri(String uri)Parse the specified GRIP URI into a config object.static booleanvalidateSig(String token, String key)Validate the specified JWT token and key.static StringwebSocketControlMessage(String type)Generate a WebSocket control message with the specified type and optional arguments.static StringwebSocketControlMessage(String type, Map<String,Object> args)Generate a WebSocket control message with the specified type and optional arguments.
-
コンストラクタの詳細
-
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
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
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
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
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
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
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
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
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, MalformedURLExceptionParse 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. -
validateSig
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
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
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
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
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
-