@ Override public void handleMessageFromClient ( WebSocketSession session , WebSocketMessage < ? > webSocketMessage , MessageChannel outputChannel ) { Assert . isInstanceOf ( TextMessage . class , webSocketMessage ) ; WampMessage wampMessage = null ; try { wampMessage = WampMessage . fromJson ( session , this . jsonFactory , ( ( TextMessage ) webSocketMessage ) . getPayload ( ) ) ; } catch ( Throwable ex ) { if ( logger . isErrorEnabled ( ) ) { logger . error ( "Failed to parse " + webSocketMessage + " in session " + session . getId ( ) + "." , ex ) ; } return ; } try { WampSessionContextHolder . setAttributesFromMessage ( wampMessage ) ; outputChannel . send ( wampMessage ) ; } catch ( Throwable ex ) { logger . error ( "Failed to send client message to application via MessageChannel" + " in session " + session . getId ( ) + "." , ex ) ; if ( wampMessage != null && wampMessage instanceof CallMessage ) { CallErrorMessage callErrorMessage = new CallErrorMessage ( ( CallMessage ) wampMessage , "" , ex . toString ( ) ) ; try { String json = callErrorMessage . toJson ( this . jsonFactory ) ; session . sendMessage ( new TextMessage ( json ) ) ; } catch ( Throwable t ) { // Could be part of normal workflow (e.g. browser tab closed) logger . debug ( "Failed to send error to client." , t ) ; } } } finally { WampSessionContextHolder . resetAttributes ( ) ; } }
Handle incoming WebSocket messages from clients .