Skip to content

Commit 5aabca4

Browse files
committed
Make a reconnection attempt in case of unexpected session termination
1 parent b638689 commit 5aabca4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

app/src/streaming/MoonlightSession.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,27 @@ void MoonlightSession::connection_started() {
7777
}
7878

7979
void MoonlightSession::connection_terminated(int error_code) {
80-
brls::Logger::info("MoonlightSession: Connection terminated...");
80+
brls::Logger::info("MoonlightSession: Connection terminated with code: {}", error_code);
81+
82+
if (error_code != 0) {
83+
if (!m_active_session) return;
84+
brls::Logger::info("MoonlightSession: Reconnection attempt");
85+
86+
m_active_session->stop(false);
87+
88+
m_active_session->start([](const GSResult<bool>& result) {
89+
if (result.isSuccess()) {
90+
brls::Logger::info("MoonlightSession: Reconnected");
91+
} else {
92+
brls::Logger::info("MoonlightSession: Reconnection failed");
93+
if (m_active_session) {
94+
m_active_session->m_is_active = false;
95+
m_active_session->m_is_terminated = true;
96+
}
97+
}
98+
});
99+
return;
100+
}
81101

82102
if (m_active_session) {
83103
m_active_session->m_is_active = false;

0 commit comments

Comments
 (0)