callOnError(wse); callOnMessageError(wse, frames);
private byte[] decompress(byte[] input) { WebSocketException wse; try { // Decompress the message. return mPMCE.decompress(input); } catch (WebSocketException e) { wse = e; } // Notify the listeners that decompression failed. callOnError(wse); callOnMessageDecompressionError(wse, input); // Create a close frame with a close code of 1003 which // indicates that the message cannot be accepted. WebSocketFrame frame = WebSocketFrame .createCloseFrame(WebSocketCloseCode.UNACCEPTABLE, wse.getMessage()); // Send the close frame. mWebSocket.sendFrame(frame); // Failed to construct a message. return null; }
/** * Call {@link WebSocketListener#onTextMessage(WebSocket, String) * onTextMessage} method of the listeners. */ private void callOnTextMessage(byte[] data) { if (mWebSocket.isDirectTextMessage()) { mWebSocket.getListenerManager().callOnTextMessage(data); return; } try { // Interpret the byte array as a string. // OutOfMemoryError may happen when the size of data is too big. String message = Misc.toStringUTF8(data); // Call onTextMessage() method of the listeners. callOnTextMessage(message); } catch (Throwable t) { // Failed to convert payload data into a string. WebSocketException wse = new WebSocketException( WebSocketError.TEXT_MESSAGE_CONSTRUCTION_ERROR, "Failed to convert payload data into a string: " + t.getMessage(), t); // Notify the listeners that text message construction failed. callOnError(wse); callOnTextMessageError(wse, data); } }
callOnError(wse); callOnFrameError(wse, frame);
callOnError(wse); callOnMessageError(wse, frames);
private byte[] decompress(byte[] input) { WebSocketException wse; try { // Decompress the message. return mPMCE.decompress(input); } catch (WebSocketException e) { wse = e; } // Notify the listeners that decompression failed. callOnError(wse); callOnMessageDecompressionError(wse, input); // Create a close frame with a close code of 1003 which // indicates that the message cannot be accepted. WebSocketFrame frame = WebSocketFrame .createCloseFrame(WebSocketCloseCode.UNACCEPTABLE, wse.getMessage()); // Send the close frame. mWebSocket.sendFrame(frame); // Failed to construct a message. return null; }
/** * Call {@link WebSocketListener#onTextMessage(WebSocket, String) * onTextMessage} method of the listeners. */ private void callOnTextMessage(byte[] data) { if (mWebSocket.isDirectTextMessage()) { mWebSocket.getListenerManager().callOnTextMessage(data); return; } try { // Interpret the byte array as a string. // OutOfMemoryError may happen when the size of data is too big. String message = Misc.toStringUTF8(data); // Call onTextMessage() method of the listeners. callOnTextMessage(message); } catch (Throwable t) { // Failed to convert payload data into a string. WebSocketException wse = new WebSocketException( WebSocketError.TEXT_MESSAGE_CONSTRUCTION_ERROR, "Failed to convert payload data into a string: " + t.getMessage(), t); // Notify the listeners that text message construction failed. callOnError(wse); callOnTextMessageError(wse, data); } }
callOnError(wse); callOnFrameError(wse, frame);