public boolean checkEventId ( String conversationId , long conversationEventId , MissingEventsListener missingEventsListener ) { if ( ! idsPerConversation . containsKey ( conversationId ) ) { TreeSet < Long > ids = new TreeSet <> ( ) ; boolean added = ids . add ( conversationEventId ) ; idsPerConversation . put ( conversationId , ids ) ; return ! added ; } else { TreeSet < Long > ids = idsPerConversation . get ( conversationId ) ; long last = ids . last ( ) ; boolean added = ids . add ( conversationEventId ) ; if ( last < conversationEventId - 1 ) { missingEventsListener . missingEvents ( conversationId , last + 1 , ( int ) ( conversationEventId - last ) ) ; } while ( ids . size ( ) > 10 ) { ids . pollFirst ( ) ; } return ! added ; } }
Check conversation event id for duplicates or missing events .