Skip to content

Commit

Permalink
Add clientCount in Java example.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 7b7dfcf77de1ab1db55dd42642b59f5b039943cb
  • Loading branch information
levlam committed Oct 13, 2020
1 parent 7a59b3d commit 358c0f2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/java/org/drinkless/tdlib/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private void processResult(int clientId, long id, TdApi.Object object) {
if (isClosed) {
updateHandlers.remove(clientId); // there will be no more updates
defaultExceptionHandlers.remove(clientId); // ignore further exceptions
clientCount.decrementAndGet();
}
}

Expand All @@ -164,6 +165,7 @@ private void processResult(int clientId, long id, TdApi.Object object) {
private static final ConcurrentHashMap<Integer, Handler> updateHandlers = new ConcurrentHashMap<Integer, Handler>();
private static final ConcurrentHashMap<Long, Handler> handlers = new ConcurrentHashMap<Long, Handler>();
private static final AtomicLong currentQueryId = new AtomicLong();
private static final AtomicLong clientCount = new AtomicLong();

private static final ResponseReceiver responseReceiver = new ResponseReceiver();

Expand All @@ -178,6 +180,7 @@ private static class Handler {
}

private Client(ResultHandler updateHandler, ExceptionHandler updateExceptionHandler, ExceptionHandler defaultExceptionHandler) {
clientCount.incrementAndGet();
nativeClientId = createNativeClient();
if (updateHandler != null) {
updateHandlers.put(nativeClientId, new Handler(updateHandler, updateExceptionHandler));
Expand Down

0 comments on commit 358c0f2

Please sign in to comment.