Skip to content

Commit

Permalink
Remove error for server receiving two consecutive start streaming mes…
Browse files Browse the repository at this point in the history
…sages (#5137)

Due to the network delay between client sending "START STREAMING" message and server actually receiving it, client might send one more "START STREAMING" message just to be on the safer side.
This is a relatively harmless behavior and does not warrant a error.

Also added a client-side logs while starting/stopping streaming
  • Loading branch information
Karthick authored Jan 11, 2022
1 parent c00de4e commit ed47079
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions protocol/client/sdl_event_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,21 +361,25 @@ int handle_sdl_event(SDL_Event *event) {
}
#ifdef __APPLE__
else if (event->window.event == SDL_WINDOWEVENT_OCCLUDED) {
LOG_INFO("SDL_WINDOWEVENT_OCCLUDED - Stop Streaming");
WhistClientMessage wcmsg = {0};
wcmsg.type = MESSAGE_STOP_STREAMING;
whist_sleep(100);
send_wcmsg(&wcmsg);
} else if (event->window.event == SDL_WINDOWEVENT_UNOCCLUDED) {
LOG_INFO("SDL_WINDOWEVENT_UNOCCLUDED - Start Streaming");
WhistClientMessage wcmsg = {0};
wcmsg.type = MESSAGE_START_STREAMING;
send_wcmsg(&wcmsg);
}
#else
else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
LOG_INFO("SDL_WINDOWEVENT_MINIMIZED - Stop Streaming");
WhistClientMessage wcmsg = {0};
wcmsg.type = MESSAGE_STOP_STREAMING;
send_wcmsg(&wcmsg);
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED) {
LOG_INFO("SDL_WINDOWEVENT_RESTORED - Start Streaming");
WhistClientMessage wcmsg = {0};
wcmsg.type = MESSAGE_START_STREAMING;
send_wcmsg(&wcmsg);
Expand Down
3 changes: 3 additions & 0 deletions protocol/client/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ int render_video(VideoContext* video_context) {
// The server thinks the client window is occluded/minimized, but it isn't. So
// we'll correct it. NOTE: Most of the time, this is just because there was a
// delay between the window losing visibility and the server reacting.
LOG_INFO(
"Server thinks the client window is occluded/minimized, but it isn't. So, Start "
"Streaming");
WhistClientMessage wcmsg = {0};
wcmsg.type = MESSAGE_START_STREAMING;
send_wcmsg(&wcmsg);
Expand Down
1 change: 0 additions & 1 deletion protocol/server/handle_client_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ static int handle_streaming_toggle_message(whist_server_state *state, WhistClien
} else {
LOG_WARNING("Received streaming message to %s streaming, but we're already in that state!",
state->stop_streaming ? "stop" : "start");
return -1;
}
return 0;
}
Expand Down

0 comments on commit ed47079

Please sign in to comment.