@Test public void testOnMessage_binary_full() { final byte[] message = new byte[16]; (new Random()).nextBytes(message); final EngineIoServer server = new EngineIoServer(); final JettyWebSocketHandler handler = Mockito.spy(new JettyWebSocketHandler(server)); handler.onWebSocketBinary(message, 0, message.length); Mockito.verify(handler, Mockito.times(1)) .emit(Mockito.eq("message"), (Object) Mockito.eq(message)); }
@Override public void onWebSocketBinary(byte[] payload, int offset, int len) { byte[] message; if((offset == 0) && (len == payload.length)) { message = payload; } else { message = new byte[len]; System.arraycopy(payload, offset, message, 0, len); } emit("message", (Object) message); }
JettyWebSocketHandler extends EngineIoWebSocket implements WebSocketListener { @Override public void onWebSocketBinary(byte[] payload, int offset, int len) { byte[] message; if((offset == 0) && (len == payload.length)) { message = payload; } else { message = new byte[len]; System.arraycopy(payload, offset, message, 0, len); } emit("message", (Object) message); } }
JettyWebSocketHandler extends EngineIoWebSocket implements WebSocketListener { @Override public void onWebSocketBinary(byte[] payload, int offset, int len) { byte[] message; if((offset == 0) && (len == payload.length)) { message = payload; } else { message = new byte[len]; System.arraycopy(payload, offset, message, 0, len); } emit("message", (Object) message); } @SuppressWarnings("WeakerAccess")  JettyWebSocketHandler(EngineIoServer server); }
JettyWebSocketHandler extends EngineIoWebSocket implements WebSocketListener { @Override public void onWebSocketBinary(byte[] payload, int offset, int len) { byte[] message; if((offset == 0) && (len == payload.length)) { message = payload; } else { message = new byte[len]; System.arraycopy(payload, offset, message, 0, len); } emit("message", (Object) message); } @SuppressWarnings("WeakerAccess")  JettyWebSocketHandler(EngineIoServer server); @Override Map<String, String> getQuery(); @Override void write(String message); @Override void write(byte[] message); @Override void close(); @Override void onWebSocketConnect(Session session); @Override void onWebSocketClose(int statusCode, String reason); @Override void onWebSocketError(Throwable cause); @Override void onWebSocketBinary(byte[] payload, int offset, int len); @Override void onWebSocketText(String message); }
JettyWebSocketHandler extends EngineIoWebSocket implements WebSocketListener { @Override public void onWebSocketBinary(byte[] payload, int offset, int len) { byte[] message; if((offset == 0) && (len == payload.length)) { message = payload; } else { message = new byte[len]; System.arraycopy(payload, offset, message, 0, len); } emit("message", (Object) message); } @SuppressWarnings("WeakerAccess")  JettyWebSocketHandler(EngineIoServer server); @Override Map<String, String> getQuery(); @Override void write(String message); @Override void write(byte[] message); @Override void close(); @Override void onWebSocketConnect(Session session); @Override void onWebSocketClose(int statusCode, String reason); @Override void onWebSocketError(Throwable cause); @Override void onWebSocketBinary(byte[] payload, int offset, int len); @Override void onWebSocketText(String message);  }