protected final void sendObjectToSocket ( Object objectToSend , WriteCallback cb ) { Session sess = this . getSession ( ) ; if ( sess != null ) { String json ; try { json = this . mapper . writeValueAsString ( objectToSend ) ; } catch ( JsonProcessingException e ) { throw new RuntimeException ( "Failed to serialize object" , e ) ; } sess . getRemote ( ) . sendString ( json , cb ) ; } }
send object to client and serialize it using JSON