MCPcopy Index your code
hub / github.com/alecgorge/jsonapi / WebSocketImpl

Class WebSocketImpl

src/main/java/org/java_websocket/WebSocketImpl.java:45–737  ·  view source on GitHub ↗

Represents one end (client or server) of a single WebSocketImpl connection. Takes care of the "handshake" phase, then allows for easy sending of text frames, and receiving frames through an event-based model.

Source from the content-addressed store, hash-verified

43 *
44 */
45public class WebSocketImpl implements WebSocket {
46
47 public static int RCVBUF = 16384;
48
49 public static/*final*/boolean DEBUG = false; // must be final in the future in order to take advantage of VM optimization
50
51 public static final List<Draft> defaultdraftlist = new ArrayList<Draft>( 4 );
52 static {
53 defaultdraftlist.add( new Draft_17() );
54 defaultdraftlist.add( new Draft_10() );
55 defaultdraftlist.add( new Draft_76() );
56 defaultdraftlist.add( new Draft_75() );
57 }
58
59 public SelectionKey key;
60
61 /** the possibly wrapped channel object whose selection is controlled by {@link #key} */
62 public ByteChannel channel;
63 /**
64 * Queue of buffers that need to be sent to the client.
65 */
66 public final BlockingQueue<ByteBuffer> outQueue;
67 /**
68 * Queue of buffers that need to be processed
69 */
70 public final BlockingQueue<ByteBuffer> inQueue;
71
72 /**
73 * Helper variable meant to store the thread which ( exclusively ) triggers this objects decode method.
74 **/
75 public volatile WebSocketWorker workerThread; // TODO reset worker?
76
77 /** When true no further frames may be submitted to be sent */
78 private volatile boolean flushandclosestate = false;
79
80 private READYSTATE readystate = READYSTATE.NOT_YET_CONNECTED;
81
82 /**
83 * The listener to notify of WebSocket events.
84 */
85 private final WebSocketListener wsl;
86
87 private List<Draft> knownDrafts;
88
89 private Draft draft = null;
90
91 private Role role;
92
93 private Opcode current_continuous_frame_opcode = null;
94
95 /** the bytes of an incomplete received handshake */
96 private ByteBuffer tmpHandshakeBytes = ByteBuffer.allocate( 0 );
97
98 /** stores the handshake sent by this websocket ( Role.CLIENT only ) */
99 private ClientHandshake handshakerequest = null;
100
101 private String closemessage = null;
102 private Integer closecode = null;

Callers

nothing calls this directly

Calls 1

addMethod · 0.45

Tested by

no test coverage detected