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.
And also, similarly, do you think the server should enforce that the client connect to all the mandatory channels? And how?On Wed, May 8, 2013 at 4:06 PM, Yonit Halperin <yhalperi@xxxxxxxxxx> wrote:
---
server/reds.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/server/reds.c b/server/reds.c
index f6a1ce9..38923b0 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -194,12 +194,37 @@ static void reds_stream_push_channel_event(RedsStream *s, int event)
main_dispatcher_channel_event(event, s->info);
}
+static const int mandatory_channels[] = {SPICE_CHANNEL_MAIN, SPICE_CHANNEL_DISPLAY, SPICE_CHANNEL_INPUTS};
+
+static int channel_is_mandatory(int type)
+{
+ int i;
+ for (i = 0 ; i < sizeof(mandatory_channels)/sizeof(mandatory_channels[0]); ++i) {
+ if (type == mandatory_channels[i]) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
void reds_handle_channel_event(int event, SpiceChannelEventInfo *info)
{
if (core->base.minor_version >= 3 && core->channel_event != NULL)
core->channel_event(event, info);
if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {
+ if (channel_is_mandatory(info->type) && reds->main_channel) {
+ RedClient *client = main_channel_get_client_by_link_id(reds->main_channel,
+ info->connection_id);
+ /* if client == NULL, it means that main channel has already been disconnected.
+ * and since main channel is a mandatory channel, reds_client_disconnect has
+ * already been called */
+ if (client) {
+ spice_debug("client %p: mandatory channel (type %d id %d)"
+ " has disconnected; closing session", client, info->type, info->id);
+ reds_client_disconnect(client);
+ }
+ }
free(info);
}
}
--
1.8.1.4
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel
--
Marc-André Lureau
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel