public void Dispose()
        {
            interruptGrabbing = false;
            serverHandler = null;
            screenResponse = null;
            packetFactory = null;
            responsePacket = null;

            try
            {
                if (ScreenThread != null && ScreenThread.IsAlive)
                    ScreenThread.Abort();
            }
            catch { }
            mouseController.Dispose();
            mouseController = null;

            keyboardController.Dispose();
            keyboardController = null;

            commander.Dispose();
            commander = null;

            screenGrabber.Dispose();
            screenGrabber = null;

            if (nextScreen != null)
                nextScreen.Dispose();
            if (prevScreen != null)
                prevScreen.Dispose();
            if (difference != null)
                difference.Dispose();

            GC.SuppressFinalize(this);
        }
예제 #2
0
        private void ProcessPacket(LdpPacket packet)
        {
            var mouseResponse = packet.MouseInfoResponse;

            MouseX = mouseResponse.X;
            MouseY = mouseResponse.Y;

            switch (packet.MouseInfoResponse.Type)
            {
            case MouseType.SET_CURSOR_POS:
                SetCursorPosition(MouseX, MouseY);
                break;

            case MouseType.LEFT_CLICK:
                MouseLeftClick();
                break;

            case MouseType.LEFT_DOUBLE_CLICK:
                MouseDoubleClick();
                break;

            case MouseType.RIGHT_CLICK:
                MouseRightClick();
                break;

            case MouseType.LEFT_BTN_DOWN:
                MouseLeftBtnDown();
                break;

            case MouseType.LEFT_BTN_UP:
                MouseLeftBtnUp();
                break;
            }
        }
        public void Handle(LdpPacket packet)
        {
            switch (packet.Type)
            {
            case PacketType.SCREEN_REQUEST:
                /*ThreadPool.QueueUserWorkItem(new WaitCallback((s) =>
                 * {
                 *  GetScreen();
                 * }));*/
                //if (ScreenThread != null && ScreenThread.IsAlive)
                //ScreenThread.Join();
                ScreenThread = new Thread(() => GetScreen());
                ScreenThread.Start();
                break;

            case PacketType.DISCONNECT_REQUEST:
                var result = packet.DisconnectRequest;
                switch (result.Type)
                {
                case DisconnectionType.FROM_SCREEN_THREAD:
                    interruptGrabbing = false;
                    LdpLog.Info("Exiting screen thread.");
                    serverHandler.GetListenerChannel.RemoveListener(this);
                    break;
                }
                break;
            }
        }
 private void ProcessPacket(LdpPacket packet)
 {
     var keyboardInfo = packet.KeyboardInfoResponse;
     string key = keyboardInfo.Key;
     KeyboardKey type = keyboardInfo.Type;
     SendKey(key, type);
 }
예제 #5
0
        public LdpPacket BuildPacket(LdpScreenResponse response)
        {
            var packet = LdpPacket.CreateBuilder();

            packet.Type           = PacketType.SCREEN_RESPONSE;
            packet.ScreenResponse = response;
            return(packet.Build());
        }
예제 #6
0
        public LdpPacket BuildPacket(LdpVolumeInfoResponse response)
        {
            var packet = LdpPacket.CreateBuilder();

            packet.Type = PacketType.VOLUME_INFO_RESPONSE;
            packet.VolumeInfoResponse = response;
            return(packet.Build());
        }
 private void SendVolumeInfoPacket(bool mute)
 {
     volumeInfoResponse = null;
     packetRequest      = null;
     volumeInfoResponse = packetFactory.SetVolumeInfoResponse(mute);
     packetRequest      = packetFactory.BuildPacket(volumeInfoResponse);
     serverHandler.GetSenderChannel.Send(packetRequest);
 }
예제 #8
0
        public LdpPacket BuildPacket(LdpPreparableDesktopInfoResponse response)
        {
            var packet = LdpPacket.CreateBuilder();

            packet.Type = PacketType.PREPARABLE_DESKTOP_INFO_RESPONSE;
            packet.PreparableDesktopResponse = response;
            return(packet.Build());
        }
 private void SendScreenResponse(byte[] compr, int len, LdpRectangle.Builder r)
 {
     screenResponse = null;
     responsePacket = null;
     screenResponse = packetFactory.SetScreenResponse(compr, len, r);
     responsePacket = packetFactory.BuildPacket(screenResponse);
     serverHandler.GetSenderChannel.Send(responsePacket);
 }
예제 #10
0
        public LdpPacket BuildPacket(LdpPreparableVolumeInfoResponse response)
        {
            var packet = LdpPacket.CreateBuilder();

            packet.Type = PacketType.PREPARABLE_VOLUME_INFO_RESPONSE;
            packet.PreparableVolumeInfoResponse = response;
            return(packet.Build());
        }
예제 #11
0
        public LdpPacket BuildPacket(LdpDisconnectRequest response)
        {
            var packet = LdpPacket.CreateBuilder();

            packet.Type = PacketType.DISCONNECT_REQUEST;
            packet.DisconnectRequest = response;
            return(packet.Build());
        }
예제 #12
0
        public LdpPacket BuildPacket(LdpAuthResponse response)
        {
            var packet = LdpPacket.CreateBuilder();

            packet.Type         = PacketType.AUTH_RESPONSE;
            packet.AuthResponse = response;
            return(packet.Build());
        }
        private void ProcessPacket(LdpPacket packet)
        {
            var         keyboardInfo = packet.KeyboardInfoResponse;
            string      key          = keyboardInfo.Key;
            KeyboardKey type         = keyboardInfo.Type;

            SendKey(key, type);
        }
예제 #14
0
 public void Dispose()
 {
     authResponse   = null;
     responsePacket = null;
     serverHandler  = null;
     userSettings   = null;
     packetFactory  = null;
     GC.SuppressFinalize(this);
 }
 public void Dispose()
 {
     serverHandler = null;
     volumeController = null;
     packetFactory = null;
     packetRequest = null;
     volumeInfoResponse = null;
     preparableVolumeResponse = null;
 }
 public void Dispose()
 {
     authResponse = null;
     responsePacket = null;
     serverHandler = null;
     userSettings = null;
     packetFactory = null;
     GC.SuppressFinalize(this);
 }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
         case PacketType.MOUSE_INFO_RESPONSE:
             ProcessPacket(packet);
             break;
     }
 }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
     case PacketType.VOLUME_INFO_RESPONSE:
         ProcessPacket(packet);
         break;
     }
 }
 public void Dispose()
 {
     serverHandler            = null;
     volumeController         = null;
     packetFactory            = null;
     packetRequest            = null;
     volumeInfoResponse       = null;
     preparableVolumeResponse = null;
 }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
     case PacketType.COMMAND:
         var command = packet.Command;
         ProcessCommand(command.Type);
         break;
     }
 }
        public void SendPreparableVolumeInfoPacket()
        {
            preparableVolumeResponse = null;
            packetRequest            = null;

            preparableVolumeResponse = packetFactory
                                       .SetPreparableVolumeInfoRequest(volumeController.VolumeValue, volumeController.Mute);
            packetRequest = packetFactory.BuildPacket(preparableVolumeResponse);
            serverHandler.GetSenderChannel.Send(packetRequest);
        }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
         case PacketType.COMMAND:
             var command = packet.Command;
             ProcessCommand(command.Type);
             break;
     }
 }
        public void SendPreparableVolumeInfoPacket()
        {
            preparableVolumeResponse = null;
            packetRequest = null;

            preparableVolumeResponse = packetFactory
                .SetPreparableVolumeInfoRequest(volumeController.VolumeValue, volumeController.Mute);
            packetRequest = packetFactory.BuildPacket(preparableVolumeResponse);
            serverHandler.GetSenderChannel.Send(packetRequest);
        }
예제 #24
0
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
     case PacketType.AUTH_REQUEST:
         //if ok - send auth response
         var auth = packet.AuthRequest;
         CheckPassword(auth.Password);
         break;
     }
 }
 public void NotifyToAllListeners(LdpPacket packet)
 {
     if (listeners != null && listeners.Count != 0)
     {
         foreach (var listener in listeners.ToList())
         {
             ILdpPacketHandler ipl = (ILdpPacketHandler)listener;
             ipl.Handle(packet);
         }
     }
 }
 public void NotifyToAllListeners(LdpPacket packet)
 {
     if (listeners != null && listeners.Count != 0)
     {
         foreach (var listener in listeners.ToList())
         {
             ILdpPacketHandler ipl = (ILdpPacketHandler)listener;
             ipl.Handle(packet);
         }
     }
 }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
         case PacketType.AUTH_REQUEST:
             //if ok - send auth response
             var auth = packet.AuthRequest;
             CheckPassword(auth.Password);
             break;
     }
 }
 private void ProcessPacket(LdpPacket packet)
 {
     switch (packet.Type)
     {
     case PacketType.DISCONNECT_REQUEST:
         switch (packet.DisconnectRequest.Type)
         {
         case DisconnectionType.FROM_SERVER:
             Restart();
             break;
         }
         break;
     }
 }
        private void ProcessPacket(LdpPacket packet)
        {
            volumeInfoResponse = packet.VolumeInfoResponse;
            switch (volumeInfoResponse.Type)
            {
            case VolumeInfoType.VOLUME:
                volumeController.VolumeValue = volumeInfoResponse.Volume;
                break;

            case VolumeInfoType.MUTE:
                volumeController.Mute = volumeInfoResponse.IsMute;
                break;
            }
        }
        protected override void Handle()
        {
            try
            {
                using (var stream = new NetworkStream(serverHandler.GetSocketChannel))
                {
                    var packet = LdpPacket.ParseDelimitedFrom(stream);

                    ProcessPacket(packet);
                    //base - notify to all subscribers
                    NotifyToAllListeners(packet);
                    //stream.Close();
                }
            }
            catch (IOException ioexc)
            {
                string error =
                    String.Format(@"LdpPacketListener IOException: 
                                    Handle() method throw:\n{0}.", ioexc.Message);
                LdpLog.Error(error);
                Restart();
            }
            catch (SocketException sockexc)
            {
                switch (sockexc.ErrorCode)
                {
                case CLIENT_DISCON_ERROR_CODE:
                    LdpLog.Info("LdpPacketListener: client disconnected.");
                    Restart();
                    break;

                default:
                    string error =
                        String.Format(@"LdpPacketListener SocketException: 
                                    Handle() method throw:\n{0}.", sockexc.Message);
                    LdpLog.Error(error);
                    Restart();
                    break;
                }
            }
            catch (Exception ex)
            {
                string error =
                    String.Format(@"LdpPacketListener Exception: 
                                    Handle() method throw:\n{0}.", ex.Message);
                LdpLog.Error(error);
                Restart();
            }
        }
        protected void DisconntectClientFromServer()
        {
            if (clientSocket != null && clientSocket.Connected)
            {
                try
                {
                    var factory = new LdpProtocolPacketFactory();
                    var list    = packetListener.GetListenersList;
                    LdpDisconnectRequest disconnectPacket = null;
                    LdpPacket            packet           = null;
                    const int            TIMEOUT          = 100;
                    if (list != null && list.Count != 0)
                    {
                        foreach (var item in list)
                        {
                            if (item is LdpRemoteDesktopSender)
                            {
                                disconnectPacket = factory
                                                   .SetDisconnectRequest(DisconnectionType.FROM_SCREEN_THREAD);
                                packet = factory.BuildPacket(disconnectPacket);
                                packetSender.Send(packet);
                                Thread.Sleep(TIMEOUT);
                                break;
                            }
                            else if (item is LdpRemoteVolumeSender)
                            {
                                disconnectPacket = factory
                                                   .SetDisconnectRequest(DisconnectionType.FROM_VOLUME_THREAD);
                                packet = factory.BuildPacket(disconnectPacket);
                                packetSender.Send(packet);
                                Thread.Sleep(TIMEOUT);
                                break;
                            }
                        }
                    }

                    disconnectPacket = factory
                                       .SetDisconnectRequest(DisconnectionType.FROM_SERVER);
                    packet = factory.BuildPacket(disconnectPacket);
                    packetSender.Send(packet);
                    disconnectPacket = null;
                    packet           = null;
                }
                catch (Exception exc)
                {
                    LdpLog.Error("DisconntectClient error.\n" + exc.Message);
                }
            }
        }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
         case PacketType.DISCONNECT_REQUEST:
             var discon = packet.DisconnectRequest;
             switch (discon.Type)
             {
                 case DisconnectionType.FROM_SERVER:
                     serverHandler.GetListenerChannel.RemoveListener(this);
                     serverHandler.Restart();
                     break;
             }
             break;
     }
 }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
     case PacketType.DISCONNECT_REQUEST:
         var discon = packet.DisconnectRequest;
         switch (discon.Type)
         {
         case DisconnectionType.FROM_SERVER:
             serverHandler.GetListenerChannel.RemoveListener(this);
             serverHandler.Restart();
             break;
         }
         break;
     }
 }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
         case PacketType.PREPARABLE_INFO_REQUEST:
             var request = packet.PreparableInfoRequest;
             switch (request.Type)
             {
                 case ConnectionType.REMOTE_DESKTOP_CONTROL:
                     SendRemoteDesktopPreparableInfo();
                     break;
                 case ConnectionType.REMOTE_VOLUME_CONTROL:
                     SendRemoteVolumePreparableInfo();
                     break;
             }
             break;
     }
 }
        public void Dispose()
        {
            interruptGrabbing = false;
            serverHandler     = null;
            screenResponse    = null;
            packetFactory     = null;
            responsePacket    = null;

            try
            {
                if (ScreenThread != null && ScreenThread.IsAlive)
                {
                    ScreenThread.Abort();
                }
            }
            catch { }
            mouseController.Dispose();
            mouseController = null;

            keyboardController.Dispose();
            keyboardController = null;

            commander.Dispose();
            commander = null;

            screenGrabber.Dispose();
            screenGrabber = null;

            if (nextScreen != null)
            {
                nextScreen.Dispose();
            }
            if (prevScreen != null)
            {
                prevScreen.Dispose();
            }
            if (difference != null)
            {
                difference.Dispose();
            }

            GC.SuppressFinalize(this);
        }
예제 #36
0
        public void Handle(LdpPacket packet)
        {
            switch (packet.Type)
            {
            case PacketType.PREPARABLE_INFO_REQUEST:
                var request = packet.PreparableInfoRequest;
                switch (request.Type)
                {
                case ConnectionType.REMOTE_DESKTOP_CONTROL:
                    SendRemoteDesktopPreparableInfo();
                    break;

                case ConnectionType.REMOTE_VOLUME_CONTROL:
                    SendRemoteVolumePreparableInfo();
                    break;
                }
                break;
            }
        }
예제 #37
0
        private void CheckPassword(string requestPassword)
        {
            if (requestPassword == settingsPassword)
            {
                infoRequest = new LdpClientInfoRequestHandler();

                authResponse   = packetFactory.SetAuthResponse(true);
                responsePacket = packetFactory.BuildPacket(authResponse);
                serverHandler.GetSenderChannel.Send(responsePacket);
                LdpLog.Info("Auth successfull.");
                serverHandler.GetListenerChannel.RemoveListener(this);
            }
            else
            {
                authResponse   = packetFactory.SetAuthResponse(false);
                responsePacket = packetFactory.BuildPacket(authResponse);
                serverHandler.GetSenderChannel.Send(responsePacket);
                LdpLog.Info("Auth failed: wrong password.");
                serverHandler.GetListenerChannel.RemoveListener(this);
            }
        }
        private void CheckPassword(string requestPassword)
        {
            if (requestPassword == settingsPassword)
            {
                infoRequest = new LdpClientInfoRequestHandler();

                authResponse = packetFactory.SetAuthResponse(true);
                responsePacket = packetFactory.BuildPacket(authResponse);
                serverHandler.GetSenderChannel.Send(responsePacket);
                LdpLog.Info("Auth successfull.");
                serverHandler.GetListenerChannel.RemoveListener(this);
            }
            else
            {
                authResponse = packetFactory.SetAuthResponse(false);
                responsePacket = packetFactory.BuildPacket(authResponse);
                serverHandler.GetSenderChannel.Send(responsePacket);
                LdpLog.Info("Auth failed: wrong password.");
                serverHandler.GetListenerChannel.RemoveListener(this);
            }
        }
예제 #39
0
        public void Handle(LdpPacket packet)
        {
            switch (packet.Type)
            {
            case PacketType.CLIENT_INFO_REQUEST:
                var clientInfo = packet.ClientInfoRequest;
                LdpClientInfo.IP          = serverHandler.GetClientIPAddress;
                LdpClientInfo.OS          = clientInfo.OS;
                LdpClientInfo.DEVICE_NAME = clientInfo.DeviceName;
                lblText.AppendLine("Client connected:");
                lblText.AppendLine("IP: " + LdpClientInfo.IP);
                lblText.AppendLine("Device: " + LdpClientInfo.DEVICE_NAME);
                lblText.AppendLine("OS: " + LdpClientInfo.OS);

                LdpLabelStatus.GetInstance().StateText = lblText.ToString();

                preparableRequestHandler = new LdpPreparableInfoRequestHandler();
                serverHandler.GetListenerChannel.RemoveListener(this);
                break;
            }
        }
        public void Handle(LdpPacket packet)
        {
            switch (packet.Type)
            {
                case PacketType.CLIENT_INFO_REQUEST:
                    var clientInfo = packet.ClientInfoRequest;
                    LdpClientInfo.IP = serverHandler.GetClientIPAddress;
                    LdpClientInfo.OS = clientInfo.OS;
                    LdpClientInfo.DEVICE_NAME = clientInfo.DeviceName;
                    lblText.AppendLine("Client connected:");
                    lblText.AppendLine("IP: " + LdpClientInfo.IP);
                    lblText.AppendLine("Device: " + LdpClientInfo.DEVICE_NAME);
                    lblText.AppendLine("OS: " + LdpClientInfo.OS);

                    LdpLabelStatus.GetInstance().StateText = lblText.ToString();

                    preparableRequestHandler = new LdpPreparableInfoRequestHandler();
                    serverHandler.GetListenerChannel.RemoveListener(this);
                    break;
            }
        }
 public void Send(LdpPacket packet)
 {
     try
     {
         using (var stream = new NetworkStream(serverHandler.GetSocketChannel))
         {
             packet.WriteDelimitedTo(stream);
         }
     }
     catch (IOException ioexc)
     {
         LdpLog.Error("Send packet error:\n" + ioexc.Message);
     }
     catch (SocketException sockexc)
     {
         LdpLog.Error("Send packet error:\n" + sockexc.Message);
     }
     catch (Exception ex)
     {
         LdpLog.Error("Send packet error:\n" + ex.Message);
     }
 }
예제 #42
0
 public void Send(LdpPacket packet)
 {
     try
     {
         using (var stream = new NetworkStream(serverHandler.GetSocketChannel))
         {
             packet.WriteDelimitedTo(stream);
         }
     }
     catch (IOException ioexc)
     {
         LdpLog.Error("Send packet error:\n" + ioexc.Message);
     }
     catch (SocketException sockexc)
     {
         LdpLog.Error("Send packet error:\n" + sockexc.Message);
     }
     catch (Exception ex)
     {
         LdpLog.Error("Send packet error:\n" + ex.Message);
     }
 }
        private void ProcessPacket(LdpPacket packet)
        {
            var mouseResponse = packet.MouseInfoResponse;
            MouseX = mouseResponse.X;
            MouseY = mouseResponse.Y;

            switch (packet.MouseInfoResponse.Type)
            {
                case MouseType.SET_CURSOR_POS:
                    SetCursorPosition(MouseX, MouseY);
                    break;
                case MouseType.LEFT_CLICK:
                    MouseLeftClick();
                    break;
                case MouseType.LEFT_DOUBLE_CLICK:
                    MouseDoubleClick();
                    break;
                case MouseType.RIGHT_CLICK:
                    MouseRightClick();
                    break;
                case MouseType.LEFT_BTN_DOWN:
                    MouseLeftBtnDown();
                    break;
                case MouseType.LEFT_BTN_UP:
                    MouseLeftBtnUp();
                    break;
            }
        }
 private void SendVolumeInfoPacket(bool mute)
 {
     volumeInfoResponse = null;
     packetRequest = null;
     volumeInfoResponse = packetFactory.SetVolumeInfoResponse(mute);
     packetRequest = packetFactory.BuildPacket(volumeInfoResponse);
     serverHandler.GetSenderChannel.Send(packetRequest);
 }
 private void ProcessPacket(LdpPacket packet)
 {
     volumeInfoResponse = packet.VolumeInfoResponse;
     switch (volumeInfoResponse.Type)
     {
         case VolumeInfoType.VOLUME:
             volumeController.VolumeValue = volumeInfoResponse.Volume;
             break;
         case VolumeInfoType.MUTE:
             volumeController.Mute = volumeInfoResponse.IsMute;
             break;
     }
 }
 public void Handle(LdpPacket packet)
 {
     switch (packet.Type)
     {
         case PacketType.SCREEN_REQUEST:
                 /*ThreadPool.QueueUserWorkItem(new WaitCallback((s) =>
                 {
                     GetScreen();
                 }));*/
             //if (ScreenThread != null && ScreenThread.IsAlive)
                 //ScreenThread.Join();
             ScreenThread = new Thread(() => GetScreen());
             ScreenThread.Start();
             break;
         case PacketType.DISCONNECT_REQUEST:
             var result = packet.DisconnectRequest;
             switch (result.Type)
             {
                 case DisconnectionType.FROM_SCREEN_THREAD:
                     interruptGrabbing = false;
                     LdpLog.Info("Exiting screen thread.");
                     serverHandler.GetListenerChannel.RemoveListener(this);
                     break;
             }
             break;
     }
 }
 private void SendScreenResponse(byte[] compr, int len, LdpRectangle.Builder r)
 {
     screenResponse = null;
     responsePacket = null;
     screenResponse = packetFactory.SetScreenResponse(compr, len, r);
     responsePacket = packetFactory.BuildPacket(screenResponse);
     serverHandler.GetSenderChannel.Send(responsePacket);
 }
 private void ProcessPacket(LdpPacket packet)
 {
     switch (packet.Type)
     {
         case PacketType.DISCONNECT_REQUEST:
             switch (packet.DisconnectRequest.Type)
             {
                 case DisconnectionType.FROM_SERVER:
                     Restart();
                     break;
             }
             break;
     }
 }