int checkAndSendMtcToSession ( Session session , JsTopicMessageController msgControl , MessageToClient mtc , Object payload ) throws SessionException { if ( session != null ) { if ( session . isOpen ( ) ) { try { if ( null != msgControl ) { checkMessageTopic ( userContextFactory . getUserContext ( session . getId ( ) ) , mtc . getId ( ) , payload , msgControl ) ; } mtc . setType ( MessageType . MESSAGE ) ; session . getAsyncRemote ( ) . sendObject ( mtc ) ; return 1 ; } catch ( NotRecipientException ex ) { logger . debug ( "{} is exclude to receive a message in {}" , ex . getMessage ( ) , mtc . getId ( ) ) ; } } else { throw new SessionException ( "CLOSED" , null , session ) ; } } return 0 ; }
Send Message to session check right before