<div dir="ltr"><div>What is the motivation for doing that? The client could want to save bandwidth by closing a display channel, or he might want to disable all inputs temporarily.<br><br></div>And also, similarly, do you think the server should enforce that the client connect to all the mandatory channels? And how?<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 8, 2013 at 4:06 PM, Yonit Halperin <span dir="ltr"><<a href="mailto:yhalperi@redhat.com" target="_blank">yhalperi@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
server/reds.c | 25 +++++++++++++++++++++++++<br>
1 file changed, 25 insertions(+)<br>
<br>
diff --git a/server/reds.c b/server/reds.c<br>
index f6a1ce9..38923b0 100644<br>
--- a/server/reds.c<br>
+++ b/server/reds.c<br>
@@ -194,12 +194,37 @@ static void reds_stream_push_channel_event(RedsStream *s, int event)<br>
main_dispatcher_channel_event(event, s->info);<br>
}<br>
<br>
+static const int mandatory_channels[] = {SPICE_CHANNEL_MAIN, SPICE_CHANNEL_DISPLAY, SPICE_CHANNEL_INPUTS};<br>
+<br>
+static int channel_is_mandatory(int type)<br>
+{<br>
+ int i;<br>
+ for (i = 0 ; i < sizeof(mandatory_channels)/sizeof(mandatory_channels[0]); ++i) {<br>
+ if (type == mandatory_channels[i]) {<br>
+ return TRUE;<br>
+ }<br>
+ }<br>
+ return FALSE;<br>
+}<br>
+<br>
void reds_handle_channel_event(int event, SpiceChannelEventInfo *info)<br>
{<br>
if (core->base.minor_version >= 3 && core->channel_event != NULL)<br>
core->channel_event(event, info);<br>
<br>
if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {<br>
+ if (channel_is_mandatory(info->type) && reds->main_channel) {<br>
+ RedClient *client = main_channel_get_client_by_link_id(reds->main_channel,<br>
+ info->connection_id);<br>
+ /* if client == NULL, it means that main channel has already been disconnected.<br>
+ * and since main channel is a mandatory channel, reds_client_disconnect has<br>
+ * already been called */<br>
+ if (client) {<br>
+ spice_debug("client %p: mandatory channel (type %d id %d)"<br>
+ " has disconnected; closing session", client, info->type, info->id);<br>
+ reds_client_disconnect(client);<br>
+ }<br>
+ }<br>
free(info);<br>
}<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Marc-André Lureau
</div>