Java Code Examples for org.springframework.messaging.simp.stomp.StompHeaderAccessor#isHeartbeat()
The following examples show how to use
org.springframework.messaging.simp.stomp.StompHeaderAccessor#isHeartbeat() .
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: WebSocketTransport.java From WeEvent with Apache License 2.0 | 5 votes |
private void handleFrame(Message<byte[]> stompMsg) { StompHeaderAccessor stompHeaderAccessor = StompHeaderAccessor.wrap(stompMsg); if (stompHeaderAccessor.isHeartbeat()) { return; } StompCommand command = stompHeaderAccessor.getCommand(); if (command == null) { log.error("miss command in stomp header"); return; } log.info("STOMP command received: {}", stompHeaderAccessor.toString()); switch (command) { // connect response case CONNECTED: // connect command always 0 futures.get(0L).setResponse(stompMsg); break; // disconnect/send/subscribe/unsubscribe response case RECEIPT: handleReceiptFrame(stompHeaderAccessor, stompMsg); break; case ERROR: handleErrorFrame(stompHeaderAccessor, stompMsg); break; case MESSAGE: handleMessageFrame(stompHeaderAccessor, stompMsg); break; default: log.error("unknown STOMP command: {}", command); break; } }
Example 2
Source File: BrokerStomp.java From WeEvent with Apache License 2.0 | 4 votes |
private void handleSingleMessage(Message<byte[]> msg, WebSocketSession session) { StompHeaderAccessor stompHeaderAccessor = StompHeaderAccessor.wrap(msg); if (stompHeaderAccessor.isHeartbeat()) { log.debug("heart beat from client: {}", session.getId()); return; } StompCommand stompCommand = stompHeaderAccessor.getCommand(); if (stompCommand == null) { log.error("miss command in stomp header, close session"); this.closeSession(session); return; } log.info("session id: {} stomp header: {} payload.length: {}", session.getId(), stompHeaderAccessor.getMessageHeaders(), msg.getPayload().length); switch (stompCommand) { case CONNECT: handleConnectMessage(stompHeaderAccessor, session); break; case DISCONNECT: handleDisconnectMessage(stompHeaderAccessor, session); break; case SEND: handleSendMessage(stompHeaderAccessor, msg, session); break; case SUBSCRIBE: handleSubscribeMessage(stompHeaderAccessor, session); break; case UNSUBSCRIBE: handleUnsubscribeMessage(stompHeaderAccessor, session); break; default: handleDefaultMessage(stompHeaderAccessor, session); break; } }