summaryrefslogtreecommitdiffstats
path: root/client/red_client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/red_client.cpp')
-rw-r--r--client/red_client.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/client/red_client.cpp b/client/red_client.cpp
index 67690e90..4a6d3fda 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -360,6 +360,7 @@ RedClient::RedClient(Application& application)
, _auto_display_res (false)
, _agent_reply_wait_type (VD_AGENT_END_MESSAGE)
, _aborting (false)
+ , _msg_attach_channels_sent(false)
, _agent_connected (false)
, _agent_mon_config_sent (false)
, _agent_disp_config_sent (false)
@@ -970,16 +971,12 @@ void RedClient::handle_init(RedPeer::InMessage* message)
if (_auto_display_res) {
send_agent_monitors_config();
}
- if (_auto_display_res || !_display_setting.is_empty()) {
- _application.activate_interval_timer(*_agent_timer, AGENT_TIMEOUT);
- } else {
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
- }
+ _application.activate_interval_timer(*_agent_timer, AGENT_TIMEOUT);
} else {
if (_auto_display_res || !_display_setting.is_empty()) {
LOG_WARN("no agent running, display options have been ignored");
}
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ send_main_attach_channels();
}
}
@@ -1026,6 +1023,15 @@ void RedClient::handle_agent_disconnected(RedPeer::InMessage* message)
_agent_connected = false;
}
+void RedClient::send_main_attach_channels(void)
+{
+ if (_msg_attach_channels_sent)
+ return;
+
+ post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ _msg_attach_channels_sent = true;
+}
+
void RedClient::on_agent_announce_capabilities(
VDAgentAnnounceCapabilities* caps, uint32_t msg_size)
{
@@ -1056,7 +1062,7 @@ void RedClient::on_agent_announce_capabilities(
if (!_display_setting.is_empty()) {
LOG_WARN("display options have been requested, but the agent doesn't support these options");
}
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ send_main_attach_channels();
_application.deactivate_interval_timer(*_agent_timer);
}
}
@@ -1076,7 +1082,7 @@ void RedClient::on_agent_reply(VDAgentReply* reply)
case VD_AGENT_MONITORS_CONFIG:
case VD_AGENT_DISPLAY_CONFIG:
if (_agent_reply_wait_type == reply->type) {
- post_message(new Message(SPICE_MSGC_MAIN_ATTACH_CHANNELS));
+ send_main_attach_channels();
_application.deactivate_interval_timer(*_agent_timer);
_agent_reply_wait_type = VD_AGENT_END_MESSAGE;
}