Example #1
0
 private void FormRoute_Shown(object sender, EventArgs e)
 {
     if (_routeId != null)
     {
         _packeteer.SendAll(Constants.CommandLables.GuiRequestRoute, _routeId);
     }
 }
Example #2
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            e.Result        = false;
            _loginResult    = false;
            _connectMessage = "Failed to connect.";

            _packeteer = new Packeteer();
            _packeteer.OnMessageReceived += Packeteer_OnMessageReceived;

            try
            {
                _worker.ReportProgress(0, new ProgressFormStatus()
                {
                    Header = "Connecting..."
                });

                if (_packeteer.Connect(_connectionInfo.ServerName, _connectionInfo.Port))
                {
                    _worker.ReportProgress(0, new ProgressFormStatus()
                    {
                        Header = "Logging in..."
                    });
                    _loginConnectionEvent = new AutoResetEvent(false);

                    UserLogin userLogin = new UserLogin()
                    {
                        UserName     = _connectionInfo.UserName,
                        PasswordHash = Library.Crypto.Hashing.Sha256(_connectionInfo.Password)
                    };

                    _packeteer.SendAll(Constants.CommandLables.GuiRequestLogin, JsonConvert.SerializeObject(userLogin));

                    if (_loginConnectionEvent.WaitOne(5000))
                    {
                        _worker.ReportProgress(0, new ProgressFormStatus()
                        {
                            Header = "Logging in..."
                        });

                        e.Result = _loginResult;

                        if (_loginResult == false)
                        {
                            _connectMessage = "Unknown user or bad password.";
                        }
                    }
                }
                else
                {
                    _connectMessage = "Could not connect to remote server.";
                }
            }
            catch (Exception ex)
            {
                _connectMessage = "An error occured while logging in: " + ex.Message;
            }

            _packeteer.Disconnect();
        }
        public static Packeteer GetNewPacketeer(ConnectionInfo connectionInfo)
        {
            Packeteer packeteer = new Packeteer();

            if (packeteer.Connect(connectionInfo.ServerName, connectionInfo.Port))
            {
                UserLogin userLogin = new UserLogin()
                {
                    UserName     = connectionInfo.UserName,
                    PasswordHash = Library.Crypto.Hashing.Sha256(connectionInfo.Password)
                };

                packeteer.SendAll(Constants.CommandLables.GuiRequestLogin, JsonConvert.SerializeObject(userLogin));
                return(packeteer);
            }

            return(null);
        }
Example #4
0
 private void FormServerSettings_Shown(object sender, EventArgs e)
 {
     _packeteer.SendAll(Constants.CommandLables.GuiRequestUserList);
 }
Example #5
0
 private void StatsTimer_Tick(object sender, EventArgs e)
 {
     _packeteer.SendAll(Constants.CommandLables.GuiRequestRouteStatsList);
 }