int sendMessageToTopicForSessions ( Collection < Session > sessions , MessageToClient mtc , Object payload ) { int sended = 0 ; JsTopicMessageController msgControl = messageControllerManager . getJsTopicMessageController ( mtc . getId ( ) ) ; Collection < Session > sessionsClosed = new ArrayList <> ( ) ; for ( Session session : sessions ) { try { sended += checkAndSendMtcToSession ( session , msgControl , mtc , payload ) ; } catch ( SessionException se ) { sessionsClosed . add ( se . getSession ( ) ) ; } } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Send message to '{}' topic {} client(s) : {}" , new Object [ ] { mtc . getId ( ) , sessions . size ( ) - sessionsClosed . size ( ) , mtc } ) ; } topicManager . removeSessionsToTopic ( sessionsClosed ) ; return sended ; }
send message to sessions apply msgControl to topic