Example usage for org.springframework.web.socket WebSocketSession getTextMessageSizeLimit

List of usage examples for org.springframework.web.socket WebSocketSession getTextMessageSizeLimit

Introduction

In this page you can find the example usage for org.springframework.web.socket WebSocketSession getTextMessageSizeLimit.

Prototype

int getTextMessageSizeLimit();

Source Link

Document

Get the configured maximum size for an incoming text message.

Usage

From source file:ch.rasc.wampspring.config.WampSubProtocolHandler.java

@Override
public void afterSessionStarted(WebSocketSession session, MessageChannel outputChannel) {
    if (session.getTextMessageSizeLimit() < MINIMUM_WEBSOCKET_MESSAGE_SIZE) {
        session.setTextMessageSizeLimit(MINIMUM_WEBSOCKET_MESSAGE_SIZE);
    }//w  ww. j  ava 2  s  .  co  m

    WelcomeMessage welcomeMessage = new WelcomeMessage(session.getId(), SERVER_IDENTIFIER);
    try {
        session.sendMessage(new TextMessage(welcomeMessage.toJson(this.jsonFactory)));
    } catch (IOException e) {
        logger.error("Failed to send welcome message to client in session " + session.getId() + ".", e);
    }
}

From source file:org.springframework.web.socket.messaging.StompSubProtocolHandler.java

@Override
public void afterSessionStarted(WebSocketSession session, MessageChannel outputChannel) {
    if (session.getTextMessageSizeLimit() < MINIMUM_WEBSOCKET_MESSAGE_SIZE) {
        session.setTextMessageSizeLimit(MINIMUM_WEBSOCKET_MESSAGE_SIZE);
    }/* www . ja  va  2 s. c  o  m*/
    this.decoders.put(session.getId(), new BufferingStompDecoder(this.stompDecoder, getMessageSizeLimit()));
}