Update InternalClient.java
This commit is contained in:
parent
bbedd3734b
commit
2647bd0d70
@ -10,6 +10,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class InternalClient implements ClientEventsHandler, TelegramClient {
|
||||
|
||||
private static final java.lang.Object CLIENT_CREATION_LOCK = new java.lang.Object();
|
||||
private final ConcurrentHashMap<Long, Handler> handlers = new ConcurrentHashMap<Long, Handler>();
|
||||
|
||||
private final int clientId;
|
||||
@ -24,28 +25,32 @@ public class InternalClient implements ClientEventsHandler, TelegramClient {
|
||||
ResultHandler updateHandler,
|
||||
ExceptionHandler updateExceptionHandler,
|
||||
ExceptionHandler defaultExceptionHandler) {
|
||||
this.updateHandler = new Handler(updateHandler, updateExceptionHandler);
|
||||
this.updatesHandler = null;
|
||||
this.defaultExceptionHandler = defaultExceptionHandler;
|
||||
this.clientManager = clientManager;
|
||||
synchronized (CLIENT_CREATION_LOCK) {
|
||||
this.updateHandler = new Handler(updateHandler, updateExceptionHandler);
|
||||
this.updatesHandler = null;
|
||||
this.defaultExceptionHandler = defaultExceptionHandler;
|
||||
this.clientManager = clientManager;
|
||||
|
||||
clientManager.preregisterClient(this);
|
||||
this.clientId = NativeClientAccess.create();
|
||||
clientManager.registerClient(clientId, this);
|
||||
clientManager.preregisterClient(this);
|
||||
this.clientId = NativeClientAccess.create();
|
||||
clientManager.registerClient(clientId, this);
|
||||
}
|
||||
}
|
||||
|
||||
public InternalClient(InternalClientManager clientManager,
|
||||
UpdatesHandler updatesHandler,
|
||||
ExceptionHandler updateExceptionHandler,
|
||||
ExceptionHandler defaultExceptionHandler) {
|
||||
this.updateHandler = null;
|
||||
this.updatesHandler = new MultiHandler(updatesHandler, updateExceptionHandler);
|
||||
this.clientManager = clientManager;
|
||||
this.defaultExceptionHandler = defaultExceptionHandler;
|
||||
synchronized (CLIENT_CREATION_LOCK) {
|
||||
this.updateHandler = null;
|
||||
this.updatesHandler = new MultiHandler(updatesHandler, updateExceptionHandler);
|
||||
this.clientManager = clientManager;
|
||||
this.defaultExceptionHandler = defaultExceptionHandler;
|
||||
|
||||
clientManager.preregisterClient(this);
|
||||
this.clientId = NativeClientAccess.create();
|
||||
clientManager.registerClient(clientId, this);
|
||||
clientManager.preregisterClient(this);
|
||||
this.clientId = NativeClientAccess.create();
|
||||
clientManager.registerClient(clientId, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user