@Override public void onSchema(final Schema schema) { try { session.getBasicRemote().sendText( mapper.writeValueAsString(EntityUtil.buildSourceSchemaEntity(schema)) ); } catch (final IOException e) { log.error("Error sending schema", e); SessionUtil.closeSilently(session, CloseCodes.PROTOCOL_ERROR, "Unable to send schema"); } }
remote.sendText(instruction);
/** * 公共方法:发送信息给所有人 */ private static void sendMessageToAll(String msg) { onlineSessions.forEach((id, session) -> { try { session.getBasicRemote().sendText(msg); } catch (IOException e) { e.printStackTrace(); } }); }
@Override public synchronized IWebSocketConnection sendMessage(String message) throws IOException { checkClosed(); session.getBasicRemote().sendText(message); return this; }
private static void sendToUser(String userId, DebugEventMetadata event) { List<Session> userSessions = RhinoJavascriptDebugProcessor.getUserSessions(userId); if (userSessions != null) { for (Session session : userSessions) { try { session.getBasicRemote().sendText(GsonHelper.GSON.toJson(event)); } catch (IOException e) { logger.error(e.getMessage(), e); } } } }
/** * 发送消息到页面 * @param message 消息内容 * @throws IOException */ public void sendMessage(String message) throws IOException { this.session.getBasicRemote().sendText(message); }
private void sendMessageToAll(String message) { sessions.forEach( session -> { try { session.getBasicRemote().sendText(message); } catch (IOException e) { LOGGER.error(e.toString()); } } ); } }
@Override public boolean doSendFrame(String payload) { if (ws != null) { try { ws.getBasicRemote().sendText(payload); return true; } catch (IOException x) { didClose(); } } return false; }
private void sendMessageToAll(String message) { sessions.forEach( session -> { try { session.getBasicRemote().sendText(message); } catch (IOException e) { LOGGER.error(e.toString()); } } ); } }
private void sendMessageToAll(String message) { sessions.forEach( session -> { try { session.getBasicRemote().sendText(message); } catch (IOException e) { LOGGER.error(e.toString()); } } ); } }
private void sendMessageToAll(String message) { sessions.forEach( session -> { try { session.getBasicRemote().sendText(message); } catch (IOException e) { LOGGER.error(e.toString()); } } ); } }
private void sendMessageToAll(String message) { sessions.forEach( session -> { try { session.getBasicRemote().sendText(message); } catch (IOException e) { LOGGER.error(e.toString()); } } ); } }
@Override public void send(JsonNode request) { synchronized (this) { if (websocketSession.isOpen()) { try { websocketSession.getBasicRemote().sendText(request.toString()); } catch (Exception e) { // Skip } } else { streamer.onClose(); } } }
public void sendMessage(String message) throws IOException { this.session.getBasicRemote().sendText(message); } }
private void send(Event event) { try { wsSession.getBasicRemote().sendText(event.toJSON()); } catch (IOException e) { e.printStackTrace(); } } }
private void sendRealTimeLog(Log log) { if (wsSession == null) { return; } try { String format = websocketLogFormat(log); wsSession.getBasicRemote().sendText(format); LogEventHandler.log.debug("Log sent: {}", format); } catch (Throwable e) { LogEventHandler.log.warn("Fail to send real time log to queue"); } }
private void sendText(Session session, String message) { RemoteEndpoint.Basic basic = session.getBasicRemote(); try { basic.sendText(message); } catch (IOException e) { e.printStackTrace(); } }
session.getBasicRemote().sendText(""); } catch (IOException e) {
@Test public void testOnSchema() throws Exception { replayOnSubscribe(); session.getBasicRemote(); EasyMock.expectLastCall().andReturn(basic).once(); final Capture<String> schema = EasyMock.newCapture(); basic.sendText(EasyMock.capture(schema)); EasyMock.expectLastCall().andThrow(new IOException("bad bad io")).once(); final Capture<CloseReason> reason = EasyMock.newCapture(); session.close(EasyMock.capture(reason)); subscription.cancel(); EasyMock.replay(subscription, session, basic); subscriber.onSchema(SchemaBuilder .struct() .field("currency", Schema.STRING_SCHEMA) .field("amount", Schema.OPTIONAL_FLOAT32_SCHEMA) .build()); subscriber.close(); assertEquals( "[" + "{\"name\":\"currency\"," + "\"schema\":{\"type\":\"STRING\",\"fields\":null,\"memberSchema\":null}}," + "{\"name\":\"amount\"," + "\"schema\":{\"type\":\"DOUBLE\",\"fields\":null,\"memberSchema\":null}}]" , schema.getValue()); assertEquals("Unable to send schema", reason.getValue().getReasonPhrase()); assertEquals(CloseCodes.PROTOCOL_ERROR, reason.getValue().getCloseCode()); EasyMock.verify(subscription, session, basic); }
@Override protected void sendTextMessage(TextMessage message) throws IOException { getNativeSession().getBasicRemote().sendText(message.getPayload(), message.isLast()); }