Reworking BaseFrame and WebSocket api classes

This commit is contained in:
Joakim Erdfelt 2012-06-18 10:28:19 -07:00
parent 1264f1aacc
commit 145b98a663
3 changed files with 64 additions and 15 deletions

View File

@ -1,12 +1,25 @@
package org.eclipse.jetty.websocket.api;
/**
* Constants for WebSocket protocol as-defined in <a href="https://tools.ietf.org/html/rfc6455">RFC-6455</a>.
*/
public class WebSocket {
/**
* Version in use by Safari / OSX
* Per <a href="https://tools.ietf.org/html/rfc6455#section-1.3">RFC 6455, section 1.3</a> - Opening Handshake - this version is "13"
*/
public static final short DRAFT0 = 0;
/**
* Version declared by RFC6455
*/
public static final short RFC6455 = 13;
public final static int VERSION=13;
public final static int CLOSE_NORMAL=1000;
public final static int CLOSE_SHUTDOWN=1001;
public final static int CLOSE_PROTOCOL=1002;
public final static int CLOSE_BAD_DATA=1003;
public final static int CLOSE_UNDEFINED=1004;
public final static int CLOSE_NO_CODE=1005;
public final static int CLOSE_NO_CLOSE=1006;
public final static int CLOSE_BAD_PAYLOAD=1007;
public final static int CLOSE_POLICY_VIOLATION=1008;
public final static int CLOSE_MESSAGE_TOO_LARGE=1009;
public final static int CLOSE_REQUIRED_EXTENSION=1010;
public final static int CLOSE_SERVER_ERROR=1011;
public final static int CLOSE_FAILED_TLS_HANDSHAKE=1015;
}

View File

@ -1,5 +1,7 @@
package org.eclipse.jetty.websocket.frames;
import org.eclipse.jetty.websocket.api.WebSocket;
/**
* A Base Frame as seen in <a href="https://tools.ietf.org/html/rfc6455#section-5.2">RFC 6455. Sec 5.2</a>
*
@ -24,13 +26,38 @@ package org.eclipse.jetty.websocket.frames;
* +---------------------------------------------------------------+
* </pre>
*/
public class BaseFrame {
private boolean fin;
private boolean rsv1;
private boolean rsv2;
private boolean rsv3;
private byte opcode = -1;
private boolean mask = false;
private long payloadLength;
private byte maskingKey[];
public class BaseFrame
{
public final static byte OP_CONTINUATION = 0x00;
public final static byte OP_TEXT = 0x01;
public final static byte OP_BINARY = 0x02;
public final static byte OP_EXT_DATA = 0x03;
public final static byte OP_CONTROL = 0x08;
public final static byte OP_CLOSE = 0x08;
public final static byte OP_PING = 0x09;
public final static byte OP_PONG = 0x0A;
public final static byte OP_EXT_CTRL = 0x0B;
private boolean fin;
private boolean rsv1;
private boolean rsv2;
private boolean rsv3;
private byte opcode = -1;
private boolean mask = false;
private long payloadLength;
private byte maskingKey[];
public final static int FLAG_FIN=0x8;
public static boolean isLastFrame(byte flags)
{
return (flags & FLAG_FIN) != 0;
}
public static boolean isControlFrame(byte opcode)
{
return (opcode & OP_CONTROL) != 0;
}
}

View File

@ -0,0 +1,9 @@
package org.eclipse.jetty.websocket.server;
/**
* <a href="https://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76">Hixie-76 Draft for WebSocket protocol</a>
* Seen in use by Safari/OSX
*/
public class WebSocketHixie76 {
/* Put Hixie-76 specifics in here */
}