@Test public void testSend() { WebSocketRouter router = new WebSocketRouter(); final WebSocketDispatcher dispatcher = mock(WebSocketDispatcher.class); router.dispatchers = new WebSocketDispatcher[]{dispatcher}; router.send("/ws", "client", "hello"); verify(dispatcher, times(1)).send("/ws", "client", "hello"); router.send("/ws", "client", "hello".getBytes(Charset.defaultCharset())); verify(dispatcher, times(1)).send("/ws", "client", "hello".getBytes(Charset.defaultCharset())); router.send("/ws", "client", (String) null); verify(dispatcher, times(0)).send("/ws", "client", (String) null); router.send("/ws", null, "hello"); verify(dispatcher, times(0)).send("/ws", null, "hello"); router.send("/ws", "client", (byte[]) null); verify(dispatcher, times(0)).send("/ws", "client", (byte[]) null); router.send("/ws", null, "hello".getBytes(Charset.defaultCharset())); verify(dispatcher, times(0)).send("/ws", null, "hello".getBytes(Charset.defaultCharset())); }
@Override public void send(String uri, String client, String message) { if (message == null || client == null) { LOGGER.warn("Cannot send websocket message on {}, either the client id is null ({}) of the message is " + "null ({})", uri, client, message); return; } for (WebSocketDispatcher dispatcher : dispatchers) { dispatcher.send(uri, client, message); } }
WebSocketRouter implements WebSocketListener, Publisher { @Override public void send(String uri, String client, String message) { if (message == null || client == null) { LOGGER.warn("Cannot send websocket message on {}, either the client id is null ({}) of the message is " + "null ({})", uri, client, message); return; } for (WebSocketDispatcher dispatcher : dispatchers) { dispatcher.send(uri, client, message); } } }
WebSocketRouter implements WebSocketListener, Publisher { @Override public void send(String uri, String client, String message) { if (message == null || client == null) { LOGGER.warn("Cannot send websocket message on {}, either the client id is null ({}) of the message is " + "null ({})", uri, client, message); return; } for (WebSocketDispatcher dispatcher : dispatchers) { dispatcher.send(uri, client, message); } }  }
WebSocketRouter implements WebSocketListener, Publisher { @Override public void send(String uri, String client, String message) { if (message == null || client == null) { LOGGER.warn("Cannot send websocket message on {}, either the client id is null ({}) of the message is " + "null ({})", uri, client, message); return; } for (WebSocketDispatcher dispatcher : dispatchers) { dispatcher.send(uri, client, message); } }  static Logger getLogger(); @Bind(aggregate = true) void bindDispatcher(WebSocketDispatcher dispatcher); @Unbind void unbindDispatcher(WebSocketDispatcher dispatcher); @Invalidate void stop(); @Bind(aggregate = true) synchronized void bindController(Controller controller); ParameterFactories converter(); ContentEngine engine(); @Unbind synchronized void unbindController(Controller controller); @Override void received(final String uri, final String from, final byte[] content); @Override void opened(String uri, String client); @Override void closed(String uri, String client); @Override void publish(String uri, String message); @Override void publish(String uri, byte[] message); @Override void publish(String uri, JsonNode message); @Override void send(String uri, String client, String message); @Override void send(String uri, String client, JsonNode message); @Override void send(String uri, String client, byte[] message); @Override Map<String, Integer> getNumberOpenedSocketsByUri(); @Override Integer getUriOpenedSockets(String uri); }
WebSocketRouter implements WebSocketListener, Publisher { @Override public void send(String uri, String client, String message) { if (message == null || client == null) { LOGGER.warn("Cannot send websocket message on {}, either the client id is null ({}) of the message is " + "null ({})", uri, client, message); return; } for (WebSocketDispatcher dispatcher : dispatchers) { dispatcher.send(uri, client, message); } }  static Logger getLogger(); @Bind(aggregate = true) void bindDispatcher(WebSocketDispatcher dispatcher); @Unbind void unbindDispatcher(WebSocketDispatcher dispatcher); @Invalidate void stop(); @Bind(aggregate = true) synchronized void bindController(Controller controller); ParameterFactories converter(); ContentEngine engine(); @Unbind synchronized void unbindController(Controller controller); @Override void received(final String uri, final String from, final byte[] content); @Override void opened(String uri, String client); @Override void closed(String uri, String client); @Override void publish(String uri, String message); @Override void publish(String uri, byte[] message); @Override void publish(String uri, JsonNode message); @Override void send(String uri, String client, String message); @Override void send(String uri, String client, JsonNode message); @Override void send(String uri, String client, byte[] message); @Override Map<String, Integer> getNumberOpenedSocketsByUri(); @Override Integer getUriOpenedSockets(String uri);  }