Exemplo n.º 1
0
        protected void RemoveGuestButtonClick(
            object sender,
            EventArgs e)
        {
            var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]);

            if (!string.IsNullOrEmpty(gatewayUrl))
            {
                var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]);
                if (connectionId != Guid.Empty)
                {
                    if (!string.IsNullOrEmpty(_guestId.Value))
                    {
                        var guestId = Guid.Empty;
                        if (Guid.TryParse(_guestId.Value, out guestId))
                        {
                            var script        = string.Empty;
                            var sharingClient = new SharingClient(string.Format("{0}/api/Sharing/", gatewayUrl));
                            if (!sharingClient.RemoveGuest(guestId))
                            {
                                script = "alert('guest not found or failed to remove guest');";
                            }
                            else
                            {
                                script = string.Format("alert('removed guest: {0}');", guestId);
                            }
                            ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), script, true);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void GetGuestsButtonClick(
            object sender,
            EventArgs e)
        {
            var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]);

            if (!string.IsNullOrEmpty(gatewayUrl))
            {
                var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]);
                if (connectionId != Guid.Empty)
                {
                    var script        = string.Empty;
                    var sharingClient = new SharingClient(string.Format("{0}/api/Sharing/", gatewayUrl));
                    var guests        = sharingClient.GetGuests(connectionId);
                    if (guests == null)
                    {
                        script = "alert('failed to retrieve the guests list');";
                    }
                    else
                    {
                        var info = string.Empty;
                        foreach (var guest in guests)
                        {
                            info += string.Format("guest: {0}, control: {1}, active: {2}, websocket: {3}\\n", guest.Id, guest.Control, guest.Active, guest.Websocket);
                        }
                        script = string.Format("alert('{0}');", info);
                    }
                    ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), script, true);
                }
            }
        }
Exemplo n.º 3
0
        // sorry for the low tech UI, it's just a mockup...

        protected void AddGuestButtonClick(
            object sender,
            EventArgs e)
        {
            var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]);

            if (!string.IsNullOrEmpty(gatewayUrl))
            {
                var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]);
                if (connectionId != Guid.Empty && !string.IsNullOrEmpty(_allowControl.Value))
                {
                    var allowControl = true;
                    if (bool.TryParse(_allowControl.Value, out allowControl))
                    {
                        var script        = string.Empty;
                        var sharingClient = new SharingClient(string.Format("{0}/api/Sharing/", gatewayUrl));
                        var guestId       = sharingClient.AddGuest(connectionId, allowControl);
                        if (guestId == Guid.Empty)
                        {
                            script = "alert('failed to add a guest');";
                        }
                        else
                        {
                            script = string.Format("prompt('Sharing link (copy & paste into a new browser tab or window):', '{0}');", string.Format("{0}?gid={1}", "http://mywebsite.com/Myrtille/", guestId));
                        }
                        ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), script, true);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void UpdateGuestButtonClick(
            object sender,
            EventArgs e)
        {
            var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]);

            if (!string.IsNullOrEmpty(gatewayUrl))
            {
                var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]);
                if (connectionId != Guid.Empty)
                {
                    if (!string.IsNullOrEmpty(_guestId.Value) && !string.IsNullOrEmpty(_allowControl.Value))
                    {
                        var guestId = Guid.Empty;
                        if (Guid.TryParse(_guestId.Value, out guestId))
                        {
                            var allowControl = true;
                            if (bool.TryParse(_allowControl.Value, out allowControl))
                            {
                                var script        = string.Empty;
                                var sharingClient = new SharingClient(string.Format("{0}/api/Sharing/", gatewayUrl));
                                var guest         = sharingClient.UpdateGuest(guestId, allowControl);
                                if (guest == null)
                                {
                                    script = "alert('guest not found or failed to update guest');";
                                }
                                else
                                {
                                    script = string.Format("alert('updated guest: {0}, control: {1}, active: {2}, websocket: {3}');", guest.Id, guest.Control, guest.Active, guest.Websocket);
                                }
                                ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), script, true);
                            }
                        }
                    }
                }
            }
        }