Esempio n. 1
0
        public void handleResponseInitalizeHostConnection(NetPeer peer, Network.Messages.Connection.Response.InitalizeHostConnectionMessage message)
        {
            NetPeer wpeer;

            if (_clientPeers.TryGetValue(message.ClientSystemId, out wpeer))
            {
                wpeer.Send(_messageHandler.encodeMessage(message), SendOptions.Unreliable);
            }
        }
Esempio n. 2
0
        public void handleRequestInitalizeHostConnection(NetPeer peer, Network.Messages.Connection.Request.InitalizeHostConnectionMessage message)
        {
            NetPeer wpeer;

            if (_hostPeers.TryGetValue(message.HostSystemId, out wpeer))
            {
                wpeer.Send(_messageHandler.encodeMessage(message), SendOptions.Unreliable);
            }
            else
            {
                Network.Messages.Connection.Response.InitalizeHostConnectionMessage messageNew = new Network.Messages.Connection.Response.InitalizeHostConnectionMessage();
                messageNew.HostFound = false;
            }
        }
Esempio n. 3
0
        public void handleResponseInitalizeHostConnection(NetPeer peer, Network.Messages.Connection.Response.InitalizeHostConnectionMessage message)
        {
            var symmetricKey = Guid.NewGuid().ToString().Replace("-", string.Empty);

            this._clientManager.SaveRemotePublicKey(message.HostSystemId, message.HostPublicKey);
            this._clientManager.SaveSymmetricKey(message.HostSystemId, symmetricKey);

            if (OnHostInitalizeConnected != null)
            {
                OnHostInitalizeConnected(this, new HostInitalizeConnectedEventArgs()
                {
                    HostSystemId = message.HostSystemId, ClientSystemId = message.ClientSystemId, HostPublicKey = message.HostPublicKey
                });
            }
        }
Esempio n. 4
0
        public void handleRequestInitalizeHostConnection(NetPeer peer, Network.Messages.Connection.Request.InitalizeHostConnectionMessage message)
        {
            this._hostManager.SaveRemotePublicKey(message.ClientSystemId, message.ClientPublicKey);
            var pair = this._hostManager.CreateNewKeyPairKey(message.ClientSystemId);

            Network.Messages.Connection.Response.InitalizeHostConnectionMessage rs = new Network.Messages.Connection.Response.InitalizeHostConnectionMessage();
            rs.HostSystemId   = this._hostManager.SystemId;
            rs.ClientSystemId = message.ClientSystemId;
            rs.HostPublicKey  = pair.PublicKey;

            this._hostManager.sendMessage(rs);
            if (OnClientInitalizeConnected != null)
            {
                OnClientInitalizeConnected(this, new ClientInitalizeConnectedEventArgs {
                    HostSystemId = message.HostSystemId, ClientSystemId = message.ClientSystemId, ClientPublicKey = message.ClientPublicKey
                });
            }
        }
Esempio n. 5
0
        public void OnStart()
        {
            f.AutoFlush = true;
            f.WriteLine("Start");
            _ScreenCapture = new ScreenCapture(80);

            f.WriteLine("Screen");


            connectionStatus          = new System.Timers.Timer(1000);
            connectionStatus.Elapsed += Connection_Elapsed;

            ConfigManager = new Common.Config.Manager();

            f.WriteLine("Server" + ConfigManager.HostConfig.ServerName);
            f.WriteLine("Configpath" + ConfigManager.ConfigPath);

            Manager.HostListener.OnConnected += new EventHandler <ConnectedEventArgs>(Network_OnConnected);

            Manager.HostListener.OnClientInitalizeConnected += (object sender, Common.EventArgs.Network.Host.ClientInitalizeConnectedEventArgs e) =>
            {
                var pair = Manager.Manager.CreateNewKeyPairKey(e.ClientSystemId);

                Network.Messages.Connection.Response.InitalizeHostConnectionMessage rs = new Network.Messages.Connection.Response.InitalizeHostConnectionMessage();
                rs.HostSystemId   = Manager.Manager.SystemId;
                rs.ClientSystemId = e.ClientSystemId;
                rs.HostPublicKey  = pair.PublicKey;

                Manager.Manager.sendMessage(rs);
            };

            Manager.HostListener.OnClientConnected += (object sender, ClientConnectedEventArgs e) =>
            {
                if (e.PasswordOk)
                {
                    f.WriteLine("Passwort Ok Verbunden mit: " + e.SystemId);
                }
                else
                {
                    f.WriteLine("Passwort Falsch Verbindung abgebrochen von: " + e.SystemId);
                }
            };
            Manager.HostListener.OnMouseMove += (object sender, MouseMoveEventArgs e) =>
            {
                Mouse.Move((int)e.X, (int)e.Y);
            };
            Manager.HostListener.OnKey += (object sender, Common.EventArgs.Network.KeyEventArgs e) =>
            {
                if (e.Mode == Network.Messages.Connection.OneWay.KeyMessage.KeyMode.Down)
                {
                    Keyboard.Down(e.Key);
                }
                else
                {
                    Keyboard.Up(e.Key);
                }
            };
            Manager.HostListener.OnMouseClick += (object sender, MouseClickEventArgs e) =>
            {
                if (e.DoubleClick)
                {
                    switch (e.Button)
                    {
                    case MouseClickEventArgs.ButtonType.Left:
                        Mouse.DoubleClickLeft((int)e.X, (int)e.Y);
                        break;

                    case MouseClickEventArgs.ButtonType.Middle:
                        Mouse.DoubleClickMiddle((int)e.X, (int)e.Y);
                        break;

                    case MouseClickEventArgs.ButtonType.Right:
                        Mouse.DoubleClickRight((int)e.X, (int)e.Y);
                        break;
                    }

                    return;
                }
                if (e.Down)
                {
                    switch (e.Button)
                    {
                    case MouseClickEventArgs.ButtonType.Left:
                        Mouse.ClickDownLeft((int)e.X, (int)e.Y);
                        break;

                    case MouseClickEventArgs.ButtonType.Middle:
                        Mouse.ClickDownMiddle((int)e.X, (int)e.Y);
                        break;

                    case MouseClickEventArgs.ButtonType.Right:
                        Mouse.ClickDownRight((int)e.X, (int)e.Y);
                        break;
                    }

                    return;
                }
                if (e.Up)
                {
                    switch (e.Button)
                    {
                    case MouseClickEventArgs.ButtonType.Left:
                        Mouse.ClickUpLeft((int)e.X, (int)e.Y);
                        break;

                    case MouseClickEventArgs.ButtonType.Middle:
                        Mouse.ClickUpMiddle((int)e.X, (int)e.Y);
                        break;

                    case MouseClickEventArgs.ButtonType.Right:
                        Mouse.ClickUpRight((int)e.X, (int)e.Y);
                        break;
                    }

                    return;
                }


                switch (e.Button)
                {
                case MouseClickEventArgs.ButtonType.Left:
                    Mouse.ClickLeft((int)e.X, (int)e.Y);
                    break;

                case MouseClickEventArgs.ButtonType.Middle:
                    Mouse.ClickMiddle((int)e.X, (int)e.Y);
                    break;

                case MouseClickEventArgs.ButtonType.Right:
                    Mouse.ClickRight((int)e.X, (int)e.Y);
                    break;
                }
            };
            Manager.HostListener.OnScreenshotRequest += HostListener_OnScreenshotRequest;
            Manager.HostListener.OnClientClose       += HostListener_OnClientClose;
            Display.SetManager(Manager.Manager);
            Manager.HostListener.onPeerConnected    += HostListener_onPeerConnected;
            Manager.HostListener.onPeerDisconnected += HostListener_onPeerDisconnected;
            Manager.HostListener.onNetworkError     += HostListener_onNetworkError;

            Manager.Start();
        }