mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Use a single PushServiceSocket
This commit is contained in:
parent
cb5cace8da
commit
5a1d2580cb
2 changed files with 23 additions and 14 deletions
|
@ -1310,6 +1310,7 @@ public class ManagerImpl implements Manager {
|
||||||
executor.close();
|
executor.close();
|
||||||
|
|
||||||
dependencies.getSignalWebSocket().disconnect();
|
dependencies.getSignalWebSocket().disconnect();
|
||||||
|
dependencies.getPushServiceSocket().close();
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.whispersystems.signalservice.api.svr.SecureValueRecoveryV2;
|
||||||
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||||
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
||||||
import org.whispersystems.signalservice.api.websocket.WebSocketFactory;
|
import org.whispersystems.signalservice.api.websocket.WebSocketFactory;
|
||||||
|
import org.whispersystems.signalservice.internal.push.PushServiceSocket;
|
||||||
import org.whispersystems.signalservice.internal.websocket.WebSocketConnection;
|
import org.whispersystems.signalservice.internal.websocket.WebSocketConnection;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -44,6 +45,7 @@ public class SignalDependencies {
|
||||||
private GroupsV2Operations groupsV2Operations;
|
private GroupsV2Operations groupsV2Operations;
|
||||||
private ClientZkOperations clientZkOperations;
|
private ClientZkOperations clientZkOperations;
|
||||||
|
|
||||||
|
private PushServiceSocket pushServiceSocket;
|
||||||
private SignalWebSocket signalWebSocket;
|
private SignalWebSocket signalWebSocket;
|
||||||
private SignalServiceMessageReceiver messageReceiver;
|
private SignalServiceMessageReceiver messageReceiver;
|
||||||
private SignalServiceMessageSender messageSender;
|
private SignalServiceMessageSender messageSender;
|
||||||
|
@ -69,6 +71,10 @@ public class SignalDependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetAfterAddressChange() {
|
public void resetAfterAddressChange() {
|
||||||
|
if (this.pushServiceSocket != null) {
|
||||||
|
this.pushServiceSocket.close();
|
||||||
|
this.pushServiceSocket = null;
|
||||||
|
}
|
||||||
this.messageSender = null;
|
this.messageSender = null;
|
||||||
this.cipher = null;
|
this.cipher = null;
|
||||||
getSignalWebSocket().forceNewWebSockets();
|
getSignalWebSocket().forceNewWebSockets();
|
||||||
|
@ -89,15 +95,24 @@ public class SignalDependencies {
|
||||||
return sessionLock;
|
return sessionLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAccountManager getAccountManager() {
|
public PushServiceSocket getPushServiceSocket() {
|
||||||
return getOrCreate(() -> accountManager,
|
return getOrCreate(() -> pushServiceSocket,
|
||||||
() -> accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.signalServiceConfiguration(),
|
() -> pushServiceSocket = new PushServiceSocket(serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||||
credentialsProvider,
|
credentialsProvider,
|
||||||
userAgent,
|
userAgent,
|
||||||
getGroupsV2Operations(),
|
getClientZkProfileOperations(),
|
||||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY));
|
ServiceConfig.AUTOMATIC_NETWORK_RETRY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SignalServiceAccountManager getAccountManager() {
|
||||||
|
return getOrCreate(() -> accountManager,
|
||||||
|
() -> accountManager = new SignalServiceAccountManager(getPushServiceSocket(),
|
||||||
|
null,
|
||||||
|
serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||||
|
credentialsProvider,
|
||||||
|
getGroupsV2Operations()));
|
||||||
|
}
|
||||||
|
|
||||||
public SignalServiceAccountManager createUnauthenticatedAccountManager(String number, String password) {
|
public SignalServiceAccountManager createUnauthenticatedAccountManager(String number, String password) {
|
||||||
return new SignalServiceAccountManager(getServiceEnvironmentConfig().signalServiceConfiguration(),
|
return new SignalServiceAccountManager(getServiceEnvironmentConfig().signalServiceConfiguration(),
|
||||||
null,
|
null,
|
||||||
|
@ -162,26 +177,19 @@ public class SignalDependencies {
|
||||||
|
|
||||||
public SignalServiceMessageReceiver getMessageReceiver() {
|
public SignalServiceMessageReceiver getMessageReceiver() {
|
||||||
return getOrCreate(() -> messageReceiver,
|
return getOrCreate(() -> messageReceiver,
|
||||||
() -> messageReceiver = new SignalServiceMessageReceiver(serviceEnvironmentConfig.signalServiceConfiguration(),
|
() -> messageReceiver = new SignalServiceMessageReceiver(pushServiceSocket));
|
||||||
credentialsProvider,
|
|
||||||
userAgent,
|
|
||||||
getClientZkProfileOperations(),
|
|
||||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceMessageSender getMessageSender() {
|
public SignalServiceMessageSender getMessageSender() {
|
||||||
return getOrCreate(() -> messageSender,
|
return getOrCreate(() -> messageSender,
|
||||||
() -> messageSender = new SignalServiceMessageSender(serviceEnvironmentConfig.signalServiceConfiguration(),
|
() -> messageSender = new SignalServiceMessageSender(credentialsProvider,
|
||||||
credentialsProvider,
|
|
||||||
dataStore,
|
dataStore,
|
||||||
sessionLock,
|
sessionLock,
|
||||||
userAgent,
|
|
||||||
getSignalWebSocket(),
|
getSignalWebSocket(),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
getClientZkProfileOperations(),
|
|
||||||
executor,
|
executor,
|
||||||
ServiceConfig.MAX_ENVELOPE_SIZE,
|
ServiceConfig.MAX_ENVELOPE_SIZE,
|
||||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY));
|
pushServiceSocket));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecureValueRecoveryV2 getSecureValueRecoveryV2() {
|
public SecureValueRecoveryV2 getSecureValueRecoveryV2() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue