Commit bf92e76b authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Send a keep-alive manually when a push is received to ensure socket isn't broken

parent c21f2412
......@@ -484,6 +484,7 @@ void Core::pushNotificationReceived () const {
* Finally if any of the connection is already pending a retry, the following code will request an immediate
* attempt to connect and register.
*/
bool sendKeepAlive = false;
while (it) {
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *) bctbx_list_get_data(it);
LinphoneRegistrationState state = linphone_proxy_config_get_state(proxy);
......@@ -493,10 +494,17 @@ void Core::pushNotificationReceived () const {
linphone_proxy_config_refresh_register(proxy);
}
} else if (state == LinphoneRegistrationOk) {
// TODO: send a keep-alive to ensure the socket isn't broken
// Send a keep-alive to ensure the socket isn't broken
sendKeepAlive = true;
}
it = bctbx_list_next(it);
}
if (sendKeepAlive) {
lInfo() << "Sending keep-alive to ensure sockets aren't broken";
getCCore()->sal->sendKeepAlive();
linphone_core_iterate(lc);
linphone_core_iterate(lc);
}
}
int Core::getUnreadChatMessageCount () const {
......
......@@ -636,6 +636,13 @@ void Sal::setKeepAlivePeriod (unsigned int value) {
}
}
void Sal::sendKeepAlive () {
for (auto it = belle_sip_provider_get_listening_points(mProvider); it; it = bctbx_list_next(it)) {
auto listeningPoint = static_cast<belle_sip_listening_point_t *>(bctbx_list_get_data(it));
belle_sip_listening_point_send_keep_alive(listeningPoint);
}
}
int Sal::setTunnel (void *tunnelclient) {
#ifdef TUNNEL_ENABLED
mTunnelClient = tunnelclient;
......
......@@ -195,6 +195,7 @@ public:
void setKeepAlivePeriod (unsigned int value);
unsigned int getKeepAlivePeriod () const { return mKeepAlive; }
void useTcpTlsKeepAlive (bool value) { mUseTcpTlsKeepAlive = value; }
void sendKeepAlive ();
void setDscp (int dscp) { belle_sip_stack_set_default_dscp(mStack, dscp); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment