Package org.springframework.web.socket

Examples of org.springframework.web.socket.TextMessage



  @Override
  public void afterConnectionEstablished(WebSocketSession session) throws Exception {

    final TextMessage tickerMessage = new TextMessage("{\"op\":\"unsubscribe\",\"channel\":\"" + MTGOX_TICKER_CHANNEL + "\"}");
    session.sendMessage(tickerMessage);

    final TextMessage message = new TextMessage("{\"op\":\"unsubscribe\",\"channel\":\"" + MTGOX_DEPTH_CHANNEL + "\"}");
    session.sendMessage(message);

    logger.debug("WebSocket connection to {} established, waiting for messages...", MTGOX_URL);

    session.sendMessage(message);
View Full Code Here


    }

    if (MTGOX_TRADES_CHANNEL.equals(channel) && "Y".equals(primary)) {
      JSONObject trade = JsonPath.compile("$.trade").read(message.getPayload());
      logger.info("Broadcasting Trade: {}", trade);
      serverWebSocketSessionsStore.sendToAll(new TextMessage(message.getPayload()));
    }
    else {
      // ignore any non-trade messages that might slip in before our
      // op:unsubscribes sent above have been handled; also ignore any
      // 'non-primary' trades. see
View Full Code Here

  }

  @Override
  public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
    String reply = this.echoService.getMessage(message.getPayload());
    session.sendMessage(new TextMessage(reply));
  }
View Full Code Here

    this.greetingService = greetingService;
  }

  @Override
  public void afterConnectionEstablished(WebSocketSession session) throws Exception {
    TextMessage message = new TextMessage(this.greetingService.getGreeting());
    session.sendMessage(message);
  }
View Full Code Here

        sendMessage("{'type': 'kill'}");
    }


    protected void sendMessage(String msg) throws Exception {
      session.sendMessage(new TextMessage(msg));
    }
View Full Code Here

      return;
    }

    try {
      if (session.isOpen()) {
        session.sendMessage(new TextMessage(json));
      } else {
        sessions.remove(session.getId());
      }
    } catch (IOException e) {
      logger.error("Sending of message '" + json + "' failed", e);
View Full Code Here

  @Override
  public void afterConnectionEstablished(WebSocketSession session) throws Exception {
    wampMessageSender.put(session.getId(), session);
    WelcomeMessage welcomeMessage = new WelcomeMessage(session.getId(), SERVER_IDENTIFIER);
    session.sendMessage(new TextMessage(welcomeMessage.toJson(jsonFactory)));
  }
View Full Code Here

    }

    String jsonMessage = request.toString();
    log.debug("Req-> {}", jsonMessage.trim());
    synchronized (wsSession) {
      wsSession.sendMessage(new TextMessage(jsonMessage));
    }

    if (responseFuture == null) {
      return null;
    }
View Full Code Here

  @Override
  public void sendResponse(Message message) throws IOException {
    String jsonMessage = message.toString();
    log.debug("<-Res {}", jsonMessage);
    synchronized (wsSession) {
      wsSession.sendMessage(new TextMessage(jsonMessage));
    }
  }
View Full Code Here

    }

    try {
      synchronized (wsSession) {
        wsSession
            .sendMessage(new TextMessage(JsonUtils.toJson(request)));
      }
    } catch (Exception e) {
      LOG.error(
          "Exception while sending message '{}' to websocket with native sessionId '{}': {}",
          JsonUtils.toJson(request), wsSession.getId(), e);
View Full Code Here

TOP

Related Classes of org.springframework.web.socket.TextMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.