1 module hunt.http.codec.websocket.model.Extension;
2 
3 import hunt.http.codec.websocket.model.ExtensionConfig;
4 
5 import hunt.http.WebSocketFrame;
6 import hunt.http.WebSocketConnection;
7 
8 /**
9  * Interface for WebSocket Extensions.
10  * <p>
11  * That {@link Frame}s are passed through the Extension via the {@link IncomingFrames} and {@link OutgoingFrames} interfaces
12  */
13 interface Extension : IncomingFrames, OutgoingFrames {
14     /**
15      * The active configuration for this extension.
16      *
17      * @return the configuration for this extension. never null.
18      */
19     ExtensionConfig getConfig();
20 
21     /**
22      * The <code>Sec-WebSocket-Extensions</code> name for this extension.
23      * <p>
24      * Also known as the <a href="https://tools.ietf.org/html/rfc6455#section-9.1"><code>extension-token</code> per Section 9.1. Negotiating Extensions</a>.
25      *
26      * @return the name of the extension
27      */
28     string getName();
29 
30     /**
31      * Used to indicate that the extension makes use of the RSV1 bit of the base websocket framing.
32      * <p>
33      * This is used to adjust validation during parsing, as well as a checkpoint against 2 or more extensions all simultaneously claiming ownership of RSV1.
34      *
35      * @return true if extension uses RSV1 for its own purposes.
36      */
37     bool isRsv1User();
38 
39     /**
40      * Used to indicate that the extension makes use of the RSV2 bit of the base websocket framing.
41      * <p>
42      * This is used to adjust validation during parsing, as well as a checkpoint against 2 or more extensions all simultaneously claiming ownership of RSV2.
43      *
44      * @return true if extension uses RSV2 for its own purposes.
45      */
46     bool isRsv2User();
47 
48     /**
49      * Used to indicate that the extension makes use of the RSV3 bit of the base websocket framing.
50      * <p>
51      * This is used to adjust validation during parsing, as well as a checkpoint against 2 or more extensions all simultaneously claiming ownership of RSV3.
52      *
53      * @return true if extension uses RSV3 for its own purposes.
54      */
55     bool isRsv3User();
56 
57     /**
58      * Set the next {@link IncomingFrames} to call in the chain.
59      *
60      * @param nextIncoming the next incoming extension
61      */
62     void setNextIncomingFrames(IncomingFrames nextIncoming);
63 
64     /**
65      * Set the next {@link OutgoingFrames} to call in the chain.
66      *
67      * @param nextOutgoing the next outgoing extension
68      */
69     void setNextOutgoingFrames(OutgoingFrames nextOutgoing);
70 }