Fix a few bugs

This commit is contained in:
Mario Danic 2018-10-25 00:28:48 +02:00
parent 8af64364b7
commit 91d0d829e0
5 changed files with 13 additions and 8 deletions

View file

@ -365,9 +365,11 @@ public class AccountVerificationController extends BaseController {
fetchAndStoreExternalSignalingSettings();
}
} else if (eventStatus.getEventType().equals(EventStatus.EventType.SIGNALING_SETTINGS)) {
if (getActivity() != null) {
getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +
getResources().getString(R.string.nc_external_server_failed)));
if (eventStatus.isAllGood()) {
if (getActivity() != null) {
getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +
getResources().getString(R.string.nc_external_server_failed)));
}
}
proceedWithLogin();

View file

@ -1194,7 +1194,7 @@ public class CallController extends BaseController {
private void setupAndInitiateWebSocketsConnection() {
webSocketConnectionHelper = new WebSocketConnectionHelper();
webSocketClient = webSocketConnectionHelper.getExternalSignalingInstanceForServer(
externalSignalingServer.getExternalSignalingServer(), false,
externalSignalingServer.getExternalSignalingServer(),
conversationUser, externalSignalingServer.getExternalSignalingTicket());
}

View file

@ -66,7 +66,7 @@ public class WebsocketConnectionsWorker extends Worker {
if (!TextUtils.isEmpty(externalSignalingServer.getExternalSignalingServer()) &&
!TextUtils.isEmpty(externalSignalingServer.getExternalSignalingTicket())) {
webSocketConnectionHelper.getExternalSignalingInstanceForServer(
externalSignalingServer.getExternalSignalingServer(), false,
externalSignalingServer.getExternalSignalingServer(),
userEntity, externalSignalingServer.getExternalSignalingTicket());
}
} catch (IOException e) {

View file

@ -77,7 +77,6 @@ public class MagicWebSocketInstance extends WebSocketListener {
Request request = new Request.Builder().url(connectionUrl).build();
this.webSocket = okHttpClient.newWebSocket(request, this);
this.conversationUser = conversationUser;
this.webSocketTicket = webSocketTicket;
this.webSocketConnectionHelper = new WebSocketConnectionHelper();
@ -231,4 +230,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
Log.e(TAG, "Failed to offer request");
}
}
public boolean isConnected() {
return connected;
}
}

View file

@ -69,11 +69,11 @@ public class WebSocketConnectionHelper {
return generatedURL;
}
public MagicWebSocketInstance getExternalSignalingInstanceForServer(String url, boolean forceReconnect, UserEntity userEntity, String webSocketTicket) {
public synchronized MagicWebSocketInstance getExternalSignalingInstanceForServer(String url, UserEntity userEntity, String webSocketTicket) {
String connectionUrl = getExternalSignalingServerUrlFromSettingsUrl(url);
if (magicWebSocketInstanceMap.containsKey(userEntity.getUserId()) && !forceReconnect) {
if (magicWebSocketInstanceMap.containsKey(userEntity.getUserId())) {
return magicWebSocketInstanceMap.get(userEntity.getUserId());
} else {
MagicWebSocketInstance magicWebSocketInstance = new MagicWebSocketInstance(userEntity, connectionUrl, webSocketTicket);