|
| 1 | +package net.tootallnate.websocket; |
| 2 | + |
| 3 | +import java.nio.charset.CharacterCodingException; |
| 4 | + |
| 5 | +public interface CloseFrame extends Framedata { |
| 6 | + /** |
| 7 | + * indicates a normal closure, meaning whatever purpose the |
| 8 | + * connection was established for has been fulfilled. |
| 9 | + */ |
| 10 | + public static final int NORMAL = 1000; |
| 11 | + /** |
| 12 | + * 1001 indicates that an endpoint is "going away", such as a server |
| 13 | + * going down, or a browser having navigated away from a page. |
| 14 | + */ |
| 15 | + public static final int GOING_AWAY = 1001; |
| 16 | + /** |
| 17 | + * 1002 indicates that an endpoint is terminating the connection due |
| 18 | + * to a protocol error. |
| 19 | + */ |
| 20 | + public static final int PROTOCOL_ERROR = 1002; |
| 21 | + /** |
| 22 | + * 1003 indicates that an endpoint is terminating the connection |
| 23 | + * because it has received a type of data it cannot accept (e.g. an |
| 24 | + * endpoint that understands only text data MAY send this if it |
| 25 | + * receives a binary message). |
| 26 | + */ |
| 27 | + public static final int REFUSE = 1003; |
| 28 | + /*1004: Reserved. The specific meaning might be defined in the future.*/ |
| 29 | + /** |
| 30 | + * 1005 is a reserved value and MUST NOT be set as a status code in a |
| 31 | + * Close control frame by an endpoint. It is designated for use in |
| 32 | + * applications expecting a status code to indicate that no status |
| 33 | + * code was actually present. |
| 34 | + */ |
| 35 | + public static final int NOCODE = 1005; |
| 36 | + /** |
| 37 | + * 1006 is a reserved value and MUST NOT be set as a status code in a |
| 38 | + * Close control frame by an endpoint. It is designated for use in |
| 39 | + * applications expecting a status code to indicate that the |
| 40 | + * connection was closed abnormally, e.g. without sending or |
| 41 | + * receiving a Close control frame. |
| 42 | + */ |
| 43 | + public static final int ABNROMAL_CLOSE = 1006; |
| 44 | + /** |
| 45 | + * 1007 indicates that an endpoint is terminating the connection |
| 46 | + * because it has received data within a message that was not |
| 47 | + * consistent with the type of the message (e.g., non-UTF-8 [RFC3629] |
| 48 | + * data within a text message). |
| 49 | + */ |
| 50 | + public static final int NO_UTF8 = 1007; |
| 51 | + /** |
| 52 | + * 1008 indicates that an endpoint is terminating the connection |
| 53 | + * because it has received a message that violates its policy. This |
| 54 | + * is a generic status code that can be returned when there is no |
| 55 | + * other more suitable status code (e.g. 1003 or 1009), or if there |
| 56 | + * is a need to hide specific details about the policy. |
| 57 | + */ |
| 58 | + public static final int POLICY_VALIDATION = 1008; |
| 59 | + /** |
| 60 | + * 1009 indicates that an endpoint is terminating the connection |
| 61 | + * because it has received a message which is too big for it to |
| 62 | + * process. |
| 63 | + */ |
| 64 | + public static final int TOOBIG = 1009; |
| 65 | + /** |
| 66 | + * 1010 indicates that an endpoint (client) is terminating the |
| 67 | + * connection because it has expected the server to negotiate one or |
| 68 | + * more extension, but the server didn't return them in the response |
| 69 | + * message of the WebSocket handshake. The list of extensions which |
| 70 | + * are needed SHOULD appear in the /reason/ part of the Close frame. |
| 71 | + * Note that this status code is not used by the server, because it |
| 72 | + * can fail the WebSocket handshake instead. |
| 73 | + */ |
| 74 | + public static final int EXTENSION = 1010; |
| 75 | + |
| 76 | + public int getCloseCode(); |
| 77 | + public String getMessage() throws CharacterCodingException; |
| 78 | +} |
0 commit comments