Java Code Examples for org.springframework.web.socket.TextMessage#getPayloadLength()

The following examples show how to use org.springframework.web.socket.TextMessage#getPayloadLength() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OfframpWebSocketHandler.java    From data-highway with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
  if (message.getPayloadLength() == 0) {
    log.warn("Road: {}, stream: {}, sessionId: {} - Ignoring message with zero sized payload", roadName, streamName,
        sessionId);
    return;
  }
  service.onEvent(message.getPayload());
}
 
Example 2
Source File: WebSocketMessageHandler.java    From jt808-server with Apache License 2.0 5 votes vote down vote up
@Override
public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
    if (message.getPayloadLength() < 1)
        return;
    for (WebSocketSession socketSession : webSocketMap.values())
        socketSession.sendMessage(message);
}