Code example for NotYetConnectedException

0
	// ////////////////////////////// 
	// ////////////////////////////////////////////////////////////////////////////////////// 
 
	private boolean _send(String text) throws IOException {
		if (!this.handshakeComplete) {
			throw new NotYetConnectedException();
		} 
		if (text == null) {
			throw new NullPointerException("Cannot send 'null' data to a WebSocket.");
		} 
 
		// Get 'text' into a WebSocket "frame" of bytes 
		byte[] textBytes = text.getBytes(UTF8_CHARSET.toString());
		ByteBuffer b = ByteBuffer.allocate(textBytes.length + 2);
		b.put(DATA_START_OF_FRAME);
		b.put(textBytes);
		b.put(DATA_END_OF_FRAME);
		b.rewind();
 
		// See if we have any backlog that needs to be sent first 
		if (_write()) {