mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
Better restarts for websocket
This commit is contained in:
parent
a8c8cc33ff
commit
dc24506aec
@ -1037,6 +1037,7 @@ public class CallController extends BaseController {
|
||||
@Override
|
||||
public void onNext(CallOverall callOverall) {
|
||||
callSession = callOverall.getOcs().getData().getSessionId();
|
||||
ApplicationWideCurrentRoomHolder.getInstance().setSession(callSession);
|
||||
callOrJoinRoomViaWebSocket();
|
||||
}
|
||||
|
||||
|
@ -482,6 +482,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
ApplicationWideCurrentRoomHolder.getInstance().setInCall(false);
|
||||
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(conversationUser);
|
||||
|
||||
|
||||
if (mentionAutocomplete != null && mentionAutocomplete.isPopupShowing()) {
|
||||
mentionAutocomplete.dismissPopup();
|
||||
}
|
||||
@ -586,6 +587,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
public void onNext(CallOverall callOverall) {
|
||||
inChat = true;
|
||||
currentCall = callOverall.getOcs().getData();
|
||||
ApplicationWideCurrentRoomHolder.getInstance().setSession(currentCall.getSessionId());
|
||||
startPing();
|
||||
if (isFirstMessagesProcessing) {
|
||||
pullChatMessages(0);
|
||||
@ -610,6 +612,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
});
|
||||
} else {
|
||||
inChat = true;
|
||||
ApplicationWideCurrentRoomHolder.getInstance().setSession(currentCall.getSessionId());
|
||||
startPing();
|
||||
if (isFirstMessagesProcessing) {
|
||||
pullChatMessages(0);
|
||||
@ -996,7 +999,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
}
|
||||
|
||||
private Intent getIntentForCall(boolean isVoiceOnlyCall) {
|
||||
if (currentCall != null && !TextUtils.isEmpty(currentCall.getSessionId())) {
|
||||
if (currentCall != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, roomId);
|
||||
|
@ -27,6 +27,7 @@ public class ApplicationWideCurrentRoomHolder {
|
||||
private String currentRoomToken = "";
|
||||
private UserEntity userInRoom = new UserEntity();
|
||||
private boolean inCall = false;
|
||||
private String session = "";
|
||||
|
||||
private static final ApplicationWideCurrentRoomHolder holder = new ApplicationWideCurrentRoomHolder();
|
||||
|
||||
@ -39,6 +40,7 @@ public class ApplicationWideCurrentRoomHolder {
|
||||
userInRoom = new UserEntity();
|
||||
inCall = false;
|
||||
currentRoomToken = "";
|
||||
session = "";
|
||||
}
|
||||
|
||||
public String getCurrentRoomToken() {
|
||||
@ -72,4 +74,12 @@ public class ApplicationWideCurrentRoomHolder {
|
||||
public void setInCall(boolean inCall) {
|
||||
this.inCall = inCall;
|
||||
}
|
||||
|
||||
public String getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setSession(String session) {
|
||||
this.session = session;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.JoinedRoomOverallWebSocketMessage;
|
||||
import com.nextcloud.talk.utils.MagicMap;
|
||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
@ -75,6 +76,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
|
||||
private String currentRoomToken;
|
||||
|
||||
int restartCount = 0;
|
||||
|
||||
MagicWebSocketInstance(UserEntity conversationUser, String connectionUrl, String webSocketTicket) {
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
@ -115,6 +118,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
switch (messageType) {
|
||||
case "hello":
|
||||
connected = true;
|
||||
restartCount = 0;
|
||||
HelloResponseOverallWebSocketMessage helloResponseWebSocketMessage = LoganSquare.parse(text, HelloResponseOverallWebSocketMessage.class);
|
||||
resumeId = helloResponseWebSocketMessage.getHelloResponseWebSocketMessage().getResumeId();
|
||||
sessionId = helloResponseWebSocketMessage.getHelloResponseWebSocketMessage().getSessionId();
|
||||
@ -205,7 +209,9 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
Log.d(TAG, "Error : " + t.getMessage());
|
||||
connected = false;
|
||||
restartWebSocket();
|
||||
if (restartCount < 4) {
|
||||
restartWebSocket();
|
||||
}
|
||||
}
|
||||
|
||||
public String getSessionId() {
|
||||
|
Loading…
Reference in New Issue
Block a user