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 {
|
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 ConcurrentHashMap<Long, Handler> handlers = new ConcurrentHashMap<Long, Handler>();
|
||||||
|
|
||||||
private final int clientId;
|
private final int clientId;
|
||||||
@ -24,6 +25,7 @@ public class InternalClient implements ClientEventsHandler, TelegramClient {
|
|||||||
ResultHandler updateHandler,
|
ResultHandler updateHandler,
|
||||||
ExceptionHandler updateExceptionHandler,
|
ExceptionHandler updateExceptionHandler,
|
||||||
ExceptionHandler defaultExceptionHandler) {
|
ExceptionHandler defaultExceptionHandler) {
|
||||||
|
synchronized (CLIENT_CREATION_LOCK) {
|
||||||
this.updateHandler = new Handler(updateHandler, updateExceptionHandler);
|
this.updateHandler = new Handler(updateHandler, updateExceptionHandler);
|
||||||
this.updatesHandler = null;
|
this.updatesHandler = null;
|
||||||
this.defaultExceptionHandler = defaultExceptionHandler;
|
this.defaultExceptionHandler = defaultExceptionHandler;
|
||||||
@ -33,11 +35,13 @@ public class InternalClient implements ClientEventsHandler, TelegramClient {
|
|||||||
this.clientId = NativeClientAccess.create();
|
this.clientId = NativeClientAccess.create();
|
||||||
clientManager.registerClient(clientId, this);
|
clientManager.registerClient(clientId, this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public InternalClient(InternalClientManager clientManager,
|
public InternalClient(InternalClientManager clientManager,
|
||||||
UpdatesHandler updatesHandler,
|
UpdatesHandler updatesHandler,
|
||||||
ExceptionHandler updateExceptionHandler,
|
ExceptionHandler updateExceptionHandler,
|
||||||
ExceptionHandler defaultExceptionHandler) {
|
ExceptionHandler defaultExceptionHandler) {
|
||||||
|
synchronized (CLIENT_CREATION_LOCK) {
|
||||||
this.updateHandler = null;
|
this.updateHandler = null;
|
||||||
this.updatesHandler = new MultiHandler(updatesHandler, updateExceptionHandler);
|
this.updatesHandler = new MultiHandler(updatesHandler, updateExceptionHandler);
|
||||||
this.clientManager = clientManager;
|
this.clientManager = clientManager;
|
||||||
@ -47,6 +51,7 @@ public class InternalClient implements ClientEventsHandler, TelegramClient {
|
|||||||
this.clientId = NativeClientAccess.create();
|
this.clientId = NativeClientAccess.create();
|
||||||
clientManager.registerClient(clientId, this);
|
clientManager.registerClient(clientId, this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getClientId() {
|
public int getClientId() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user