public 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);
		ByteBuffer b = ByteBuffer.allocate(textBytes.length + 2);
		b.put(START_OF_FRAME);
		b.put(textBytes);
		b.put(END_OF_FRAME);
		b.rewind();

		// See if we have any backlog that needs to be sent first
		if (handleWrite()) {
			// Write the ByteBuffer to the socket
			this.socketChannel.write(b);
		}

		// If we didn't get it all sent, add it to the buffer of buffers
		if (b.remaining() > 0) {
			if (!this.bufferQueue.offer(b)) {
				throw new IOException("Buffers are full, message could not be sent to" +
						this.socketChannel.socket().getRemoteSocketAddress());
			}
			return false;
		}

		return true;
	}