* @throws WebSocketException
* @throws IOException
*/
private int readNextFrame() throws WebSocketException, IOException {
boolean ping;
WebSocketFrame readResult;
do {
readResult = WebSocketFrame.readFrame(in);
if (readResult.bytesRead == -1) { return -1; }
if (readResult.masked == false) {
throw new WebSocketException("Received an unmasked frame from client.");