Example #1
0
        private async void OnControlRelinquished(object sender, ClientConnectionChangedEventArgs e)
        {
            await EnsureInitialized();

            await mutableStateLock.WaitAsync();

            string desktopName = e.DesktopName.NormalizeDesktopName();

            if (localState is LocalState.Controlled controlled)
            {
                HashSet <string> by = new HashSet <string>(controlled.By);
                by.Remove(desktopName);
                if (by.Count == 0)
                {
                    DebugMessage("no controllers left, becoming relinquished");
                    localState = new LocalState.Relinquished();
                    DebugMessage("blocking local input");
                    inputManager.BlockInput(true);
                }
                else
                {
                    DebugMessage("controllers remaining, not relinquished");
                    localState = new LocalState.Controlled(by);
                }
            }

            mutableStateLock.Release();
        }
Example #2
0
 // <summary>
 /// Connection state has changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnConnectionChanged(object sender, ClientConnectionChangedEventArgs e)
 {
     if (_connected == true && e.IsConnected == false)
     {
         MessageBox.Show("Connection lost");
         Invoke(new Action(() => {
             tabControlExam.Enabled       = false;
             btnSendResults.Enabled       = false;
             button_selectnewtest.Visible = false;
         }));
     }
     _connected = e.IsConnected;
 }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public string ProcessConnectionState(ClientConnectionChangedEventArgs e)
        {
            string info;

            if (e.IsConnected)
            {
                info = "Client: " + e.IP + " connected";
            }
            else
            {
                info = "Client: " + e.IP + " disconnected";
            }
            return(info);
        }
Example #4
0
        private async void OnClientResignedFromControl(object sender, ClientConnectionChangedEventArgs e)
        {
            await EnsureInitialized();

            await mutableStateLock.WaitAsync();

            string desktopName = e.DesktopName.NormalizeDesktopName();

            if (localState is LocalState.Controlling controlling && controlling.ActiveDesktop.Name == desktopName)
            {
                DebugMessage($"client {desktopName} has resigned from being controlled");
                await ReturnToPrimaryDisplay();
            }

            mutableStateLock.Release();
        }
Example #5
0
        private async void OnClientDisconnected(object sender, ClientConnectionChangedEventArgs e)
        {
            await EnsureInitialized();

            await mutableStateLock.WaitAsync();

            string desktopName = e.DesktopName.NormalizeDesktopName();

            LocalState.Controlling?controlling = localState as LocalState.Controlling;
            string?activeDisplayId             = null;

            if (controlling != null && controlling.ActiveDesktop.Name != desktopName)
            {
                activeDisplayId = displayLayout.DisplayIds[controlling.ActiveDisplay];
            }

            DebugMessage($"removing client {desktopName}");
            desktops      = desktops.Where(d => d.Name != desktopName).ToList();
            displayLayout = new DisplayLayout(desktops);
            DebugPrintDisplays();

            if (controlling != null)
            {
                if (activeDisplayId != null)
                {
                    var nextDisplay = displayLayout.DisplayById[activeDisplayId];
                    DebugMessage($"moving from display {controlling.ActiveDisplay} to {nextDisplay}");
                    var displayOriginDeltaX = nextDisplay.X - controlling.ActiveDisplay.X;
                    var displayOriginDeltaY = nextDisplay.Y - controlling.ActiveDisplay.Y;
                    localState = new LocalState.Controlling(controlling.ActiveDesktop, nextDisplay, controlling.CursorPosition.Offset(displayOriginDeltaX, displayOriginDeltaY));
                }
                else
                {
                    DebugMessage($"active desktop disconnected. Returning to local primary display");
                    await ReturnToPrimaryDisplay();
                }
            }

            mutableStateLock.Release();
        }
Example #6
0
        private async void OnClientConnected(object sender, ClientConnectionChangedEventArgs e)
        {
            await EnsureInitialized();

            string desktopName = e.DesktopName.NormalizeDesktopName();

            if (desktopName == selfName)
            {
                return;
            }

            await mutableStateLock.WaitAsync();

            LocalState.Controlling?controlling = localState as LocalState.Controlling;
            string?activeDisplayId             = null;

            if (controlling != null)
            {
                activeDisplayId = displayLayout.DisplayIds[controlling.ActiveDisplay];
            }

            DebugMessage($"adding client {desktopName}");
            desktops.Add(new Desktop()
            {
                Name = desktopName
            });
            displayLayout = CreateDisplayLayout(configurationProvider.GetDesktopOrder());
            DebugPrintDisplays();

            if (controlling != null && activeDisplayId != null)
            {
                var nextDisplay         = displayLayout.DisplayById[activeDisplayId];
                var displayOriginDeltaX = nextDisplay.X - controlling.ActiveDisplay.X;
                var displayOriginDeltaY = nextDisplay.Y - controlling.ActiveDisplay.Y;
                localState = new LocalState.Controlling(controlling.ActiveDesktop, nextDisplay, controlling.CursorPosition.Offset(displayOriginDeltaX, displayOriginDeltaY));
            }

            mutableStateLock.Release();
        }
Example #7
0
        private async void OnControlAssumed(object sender, ClientConnectionChangedEventArgs e)
        {
            await EnsureInitialized();

            await mutableStateLock.WaitAsync();

            string desktopName = e.DesktopName.NormalizeDesktopName();

            if (localState is LocalState.Controlling controlling)
            {
                var client = await workspaceNetwork.GetClientDesktop(controlling.ActiveDesktop.Name);

                if (client != null)
                {
                    DebugMessage($"controlling {controlling.ActiveDesktop.Name}, relinquishing");
                    await client.RelinquishControl();
                }
            }

            HashSet <string> by;

            if (localState is LocalState.Controlled controlled)
            {
                by = new HashSet <string>(controlled.By);
            }
            else
            {
                by = new HashSet <string>();
            }
            DebugMessage($"adding {desktopName} to controlled by");
            by.Add(desktopName);
            localState = new LocalState.Controlled(by);
            DebugMessage("unblocking local input");
            inputManager.BlockInput(false);

            mutableStateLock.Release();
        }
Example #8
0
 private void OnClientConnectionChanged(ClientConnectionChangedEventArgs e)
 {
     ClientConnectionChanged?.Invoke(this, e);
 }
 /// <summary>
 /// On Connection Changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnConnectionChanged(object sender, ClientConnectionChangedEventArgs e)
 {
     _isconnected = e.IsConnected;
 }
Example #10
0
 protected void OnConnectionChanged(ClientConnectionChangedEventArgs e)
 {
     Connection?.Invoke(this, e);
 }
Example #11
0
        /// <summary>
        /// If connection state has changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnConnectionChanged(object sender, ClientConnectionChangedEventArgs e)
        {
            PacketHandler h = new PacketHandler();

            _log.AppendToLog(h.ProcessConnectionState(e), LogType.Connection);
        }