Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Process missing messages during reconnection. #536

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions talk/owt/sdk/conference/conferencesocketsignalingchannel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <thread>
#include <algorithm>
#include <ctime>
#include <climits>
#if defined(WEBRTC_IOS)
#include <CoreFoundation/CFDate.h>
#endif
Expand All @@ -25,7 +26,6 @@ const std::string kEventNameCustomMessage = "customMessage";
const std::string kEventNameSignalingMessagePrelude = "signaling";
const std::string kEventNameSignalingMessage = "soac"; //only for soac message
const std::string kEventNameOnSignalingMessage = "progress";
const std::string kEventNameOnCustomMessage = "text";
const std::string kEventNameSubscribe = "subscribe";
const std::string kEventNameUnsubscribe = "unsubscribe";
const std::string kEventNamePublish = "publish";
Expand Down Expand Up @@ -71,7 +71,8 @@ ConferenceSocketSignalingChannel::ConferenceSocketSignalingChannel()
participant_id_(""),
reconnection_attempted_(0),
is_reconnection_(false),
outgoing_message_id_(1) {}
outgoing_message_id_(1),
message_sequence_(0) {}
ConferenceSocketSignalingChannel::~ConferenceSocketSignalingChannel() {
delete socket_client_;
}
Expand Down Expand Up @@ -272,8 +273,19 @@ void ConferenceSocketSignalingChannel::Connect(
// The second element is room info, please refer to server's
// portal implementation for detailed message format.
sio::message::ptr message = msg.at(1);
if (message->get_flag() == sio::message::flag_string) {
OnReconnectionTicket(message->get_string());
if (message->get_flag() == sio::message::flag_object) {
OnReconnectionTicket(message->get_map()["ticket"]->get_string());
std::vector<sio::message::ptr> notifications =
message->get_map()["messages"]->get_vector();
for (sio::message::ptr notification : notifications) {
int seq=notification->get_map()["seq"]->get_int();
if(seq<=message_sequence_){
continue;
}
sio::message::ptr notification_data=notification->get_map()["data"];
std::string event_name=notification->get_map()["event"]->get_string();
OnNotificationFromServer(event_name, notification_data);
}
}
RTC_LOG(LS_VERBOSE) << "Reconnection success";
DrainQueuedMessages();
Expand Down Expand Up @@ -431,6 +443,11 @@ void ConferenceSocketSignalingChannel::OnNotificationFromServer(
(*it)->OnServerDisconnected();
}
}
if (message_sequence_ < INT_MAX) {
message_sequence_++;
} else {
message_sequence_ = 0;
}
}

void ConferenceSocketSignalingChannel::SendSubscriptionUpdateMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class ConferenceSocketSignalingChannel
std::queue<SioMessage> outgoing_messages_;
int outgoing_message_id_;
std::mutex outgoing_message_mutex_;
int message_sequence_;
std::string quic_transport_id_;
};
}
Expand Down