Java Code Examples for org.springframework.web.socket.BinaryMessage

Following code examples demonstrate how to use org.springframework.web.socket.BinaryMessagefrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.web.socket.BinaryMessageand various code implementation of this class.

  public static synchronized boolean send(WebSocketSession session, String msg){

    if (!session.isOpen()) {
      return false; 
    }
    try {
      session.sendMessage(new BinaryMessage(msg.getBytes())); 
    } catch (IOException e) {
      e.printStackTrace();
    }
    return true;
  } 


	protected void doBinaryMessageInterceptor(WebSocketSession session, BinaryMessage message, InterceptorChain chain) {
		System.out.println("binary handler");
		chain.doChain(session, message);
	} 

    public void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception {
        super.handleBinaryMessage(session, message);
        BinaryMessage binaryMessage = new BinaryMessage(message.getPayload());
        
    } 

  protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception {
    super.handleBinaryMessage(session, message);
    System.out.println(message.getPayload().array());
  } 

    protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) {
    	logger.debug("handleBinaryMessage");
    	super.handleBinaryMessage(session, message);
    } 

    protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception {
        System.out.println(message.getPayload());
        message.getPayload().array();
    } 

Advertisement
Javadoc
A binary WebSocket message. @author Rossen Stoyanchev @since 4.0
Advertisement