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