internal void RegisterNewWebSocketClient(string clientHashCode)
        {
            this.LoggingService.LogMessage($"User Connected : ${clientHashCode}");
            Client newClient = new Client(clientHashCode);

            if (!Clients.ContainsKey(clientHashCode))
            {
                Clients.Add(clientHashCode, new Client(clientHashCode));
            }
            else
            {
                throw new ClientAlreadyAddedException();
            }

            OnNewClientRegistred?.Invoke(this, newClient);
        }
Esempio n. 2
0
        protected override void ListenOnNewClients()
        {
            Listener.Start();

            while (true)
            {
                TcpClient connectedClient = Listener.AcceptTcpClient();
                var       sslStream       = ProcessClient(connectedClient);

                var client = HandleNewConnectedClient(connectedClient, sslStream);

                Clients.Add(client);
                OnClientConnected(new ClientConnectedEventArgs(client));
                Log.Info("New Client connected (IP: " + connectedClient.Client.RemoteEndPoint + ")");
            }
        }
Esempio n. 3
0
 public void GetSurname(string sn)
 {
     Clients.Clear();
     if (sn == "")
     {
         GetAllPerson();
     }
     else
     {
         Client[] cl = AllClients.Where(i => i.Surname == sn).ToArray <Client>();
         foreach (Client c in cl)
         {
             Clients.Add(c);
         }
     }
 }
        private void InitializeDefaultUsers()
        {
            //--Credentials
            //[email protected]  P@ssw0rd_admin
            //[email protected]      P@ssw0rd_accountant
            //[email protected]          P@ssw0rd_deputy

            const string sql = "INSERT INTO AspNetUsers(Id, FirstName, LastName, UserName, NormalizedUserName, Email, NormalizedEmail, EmailConfirmed, PasswordHash, SecurityStamp, ConcurrencyStamp, PhoneNumber, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnd, LockoutEnabled, AccessFailedCount) VALUES " +
                               "('80c3b9e5-48f0-43dc-9226-dc05f13cd471','Griffin','Stewie','*****@*****.**','*****@*****.**','*****@*****.**','*****@*****.**',0,'AQAAAAEAACcQAAAAEIpy4VbmDRxJOayhY6V2VSnGY+TtihLeiAxuHHcfpw++bIz5Qh1Zt/J3fQIU7MmojA==','7W3OKJNGBY43TZIF4B2U5QY5GRDG2WAX','03e08ee0-4d03-42d0-81a7-9f80d4f5151a',NULL,0,0,NULL,1,0), " +
                               "('bce59a46-2f93-4ab2-9e71-a023f7a851db','Griffin','Peter','*****@*****.**','*****@*****.**','*****@*****.**','*****@*****.**',0,'AQAAAAEAACcQAAAAEJmfjCDspGDCNMU0UKXmZ4aOqJ/kZr37HrVv1MWBDlHjSSfPBEqYBFrFTJYMFcUf2w==','O7GGVB4T3E2N4QRC6C2PC6GOML6WQ4VT','b320746f-de84-4ca9-ad12-be70aa943a20',NULL,0,0,NULL,1,0), " +
                               "('a2fd029e-f6d0-49aa-b3ca-c49d645bf41f','Griffin','Lois','*****@*****.**','*****@*****.**','*****@*****.**','*****@*****.**',0,'AQAAAAEAACcQAAAAEEHFo6yQWrGPFQwPUOFDtZ0V7C+F/oajrxJHWeeiWFZUVeP6AQKZ03+D66p0/wtQqQ==','N7SFWMK4W2XGIK4DFK3XAQMCW6FOQCXL','68f3773b-d59a-45fa-8763-519f60816d3d',NULL,0,0,NULL,1,0); " +

                               "INSERT INTO AspNetRoles(Id, Name, NormalizedName, ConcurrencyStamp) VALUES " +
                               "('c2c50d82-63d5-4764-a1b0-2919a826a4e6','Admin','ADMIN','7f5ebe86-e5d5-4c70-9f4e-467ff3c4d2d3'), " +
                               "('0c277213-cf17-4be6-966f-316233db2dc5','Accountant','ACCOUNTANT','f61ce026-bd54-4882-85c8-fe6ec3cc8227'), " +
                               "('121b555e-1037-4d80-90cc-1b5101d1af6d','Deputy','DEPUTY','80e5d186-5075-4cc4-ab95-5b70dbef7f2e'); " +

                               "INSERT INTO AspNetUserRoles(UserId, RoleId) VALUES " +
                               "('80c3b9e5-48f0-43dc-9226-dc05f13cd471','c2c50d82-63d5-4764-a1b0-2919a826a4e6'), " +
                               "('bce59a46-2f93-4ab2-9e71-a023f7a851db','0c277213-cf17-4be6-966f-316233db2dc5'), " +
                               "('a2fd029e-f6d0-49aa-b3ca-c49d645bf41f','121b555e-1037-4d80-90cc-1b5101d1af6d');";

            using (var dr = Database.ExecuteSqlQuery(sql))
            {
                dr.Close();
            }

            Clients.Add(new Client
            {
                ClientId             = "WEB-APPLICATION",
                RefreshTokenLifeTime = 86400 //60 days
            });

            Clients.Add(new Client
            {
                ClientId             = "DESKTOP-APPLICATION",
                RefreshTokenLifeTime = 86400 //60 days
            });

            Clients.Add(new Client
            {
                ClientId             = "MOBILE-APPLICATION",
                RefreshTokenLifeTime = 86400 //60 days
            });

            SaveChanges();
        }
Esempio n. 5
0
        private void Process(object target)
        {
            Socket client = (Socket)target;

            Clients.Add(((IPEndPoint)client.RemoteEndPoint).Port, client);
            byte[] receive = new byte[client.ReceiveBufferSize];
            try
            {
                int rec;
                while (client.Connected)
                {
                    // sleep 250ms to avoid race condition
                    Thread.Sleep(250);
                    receive = new byte[client.ReceiveBufferSize];
                    rec     = client.Receive(receive);
                    if (rec == 0)
                    {
                        break;
                    }
                    Array.Resize <byte>(ref receive, rec);
                    OnPacketReceived(new PacketEventArgs(client, receive, Encoding));
                }
            }
            catch (ObjectDisposedException)
            { }
            catch (SocketException soex)
            {
                if (soex.ErrorCode != 10004)
                {
                    if ((soex.SocketErrorCode == SocketError.ConnectionReset) ||
                        (soex.SocketErrorCode == SocketError.ConnectionAborted) ||
                        (soex.SocketErrorCode == SocketError.NotConnected) ||
                        (soex.SocketErrorCode == SocketError.Shutdown) ||
                        (soex.SocketErrorCode == SocketError.Disconnecting))
                    {
                        System.Diagnostics.Debug.WriteLine(ResourceMessages.CONNETION_CLOSED, soex.SocketErrorCode);
                    }
                }
            }
            finally
            {
                Clients.Remove(((IPEndPoint)client.RemoteEndPoint).Port);
                OnDisconnected(new SocketEventArgs(client));
                client.Close();
                client.Dispose();
            }
        }
Esempio n. 6
0
        private void InitializeDefaultUsers()
        {
            //--Credentials
            //[email protected]  P@ssw0rd_admin
            //[email protected]      P@ssw0rd_accountant
            //[email protected]          P@ssw0rd_deputy

            const string sql = "INSERT INTO \"AspNetUsers\"(\"Id\", \"FirstName\", \"LastName\", \"UserName\", \"NormalizedUserName\", \"Email\", \"NormalizedEmail\", \"EmailConfirmed\", \"PasswordHash\", \"SecurityStamp\", \"ConcurrencyStamp\", \"PhoneNumber\", \"PhoneNumberConfirmed\", \"TwoFactorEnabled\", \"LockoutEnd\", \"LockoutEnabled\", \"AccessFailedCount\") VALUES\r\n " +
                               "(\'80c3b9e5-48f0-43dc-9226-dc05f13cd471\',\'Griffin\',\'Stewie\',\'[email protected]\',\'[email protected]\',\'[email protected]\',\'[email protected]\',FALSE,\'AQAAAAEAACcQAAAAEIpy4VbmDRxJOayhY6V2VSnGY+TtihLeiAxuHHcfpw++bIz5Qh1Zt/J3fQIU7MmojA==\',\'7W3OKJNGBY43TZIF4B2U5QY5GRDG2WAX\',\'03e08ee0-4d03-42d0-81a7-9f80d4f5151a\',NULL,FALSE,FALSE,NULL,TRUE,0),\r\n " +
                               "(\'bce59a46-2f93-4ab2-9e71-a023f7a851db\',\'Griffin\',\'Peter\',\'[email protected]\',\'[email protected]\',\'[email protected]\',\'[email protected]\',FALSE,\'AQAAAAEAACcQAAAAEJmfjCDspGDCNMU0UKXmZ4aOqJ/kZr37HrVv1MWBDlHjSSfPBEqYBFrFTJYMFcUf2w==\',\'O7GGVB4T3E2N4QRC6C2PC6GOML6WQ4VT\',\'b320746f-de84-4ca9-ad12-be70aa943a20\',NULL,FALSE,FALSE,NULL,TRUE,0),\r\n " +
                               "(\'a2fd029e-f6d0-49aa-b3ca-c49d645bf41f\',\'Griffin\',\'Lois\',\'[email protected]\',\'[email protected]\',\'[email protected]\',\'[email protected]\',FALSE,\'AQAAAAEAACcQAAAAEEHFo6yQWrGPFQwPUOFDtZ0V7C+F/oajrxJHWeeiWFZUVeP6AQKZ03+D66p0/wtQqQ==\',\'N7SFWMK4W2XGIK4DFK3XAQMCW6FOQCXL\',\'68f3773b-d59a-45fa-8763-519f60816d3d\',NULL,FALSE,FALSE,NULL,TRUE,0); " +

                               "INSERT INTO \"AspNetRoles\"(\"Id\", \"Name\", \"NormalizedName\", \"ConcurrencyStamp\") VALUES\r\n " +
                               "(\'c2c50d82-63d5-4764-a1b0-2919a826a4e6\',\'Admin\',\'ADMIN\',\'7f5ebe86-e5d5-4c70-9f4e-467ff3c4d2d3\'),\r\n " +
                               "(\'0c277213-cf17-4be6-966f-316233db2dc5\',\'Accountant\',\'ACCOUNTANT\',\'f61ce026-bd54-4882-85c8-fe6ec3cc8227\'),\r\n " +
                               "(\'121b555e-1037-4d80-90cc-1b5101d1af6d\',\'Deputy\',\'DEPUTY\',\'80e5d186-5075-4cc4-ab95-5b70dbef7f2e\'); " +

                               "INSERT INTO \"AspNetUserRoles\"(\"UserId\", \"RoleId\") VALUES\r\n " +
                               "(\'80c3b9e5-48f0-43dc-9226-dc05f13cd471\',\'c2c50d82-63d5-4764-a1b0-2919a826a4e6\'),\r\n " +
                               "(\'bce59a46-2f93-4ab2-9e71-a023f7a851db\',\'0c277213-cf17-4be6-966f-316233db2dc5\'),\r\n " +
                               "(\'a2fd029e-f6d0-49aa-b3ca-c49d645bf41f\',\'121b555e-1037-4d80-90cc-1b5101d1af6d\');";

            using (var dr = Database.ExecuteSqlQuery(sql))
            {
                dr.DbDataReader.Close();
            }

            Clients.Add(new Client
            {
                Id = "WEB-APPLICATION",
                RefreshTokenLifeTime = 86400 //60 days
            });

            Clients.Add(new Client
            {
                Id = "DESKTOP-APPLICATION",
                RefreshTokenLifeTime = 86400 //60 days
            });

            Clients.Add(new Client
            {
                Id = "MOBILE-APPLICATION",
                RefreshTokenLifeTime = 86400 //60 days
            });

            SaveChanges();
        }
        private void SaveClient(int id)
        {
            if (!WinApiMessageBox.ConfirmAction("Сохранить изменения?"))
            {
                return;
            }

            if (id == 0)
            {
                Clients.Add(SelectedClient);
                _context.Clients.Add(SelectedClient.Client);
            }

            _context.SaveChanges();
            OnPropertyChanged("Clients");
            SelectedClientVisibility = Visibility.Collapsed;
        }
        public void AddClientData(Message message)
        {
            ClientData cd = new ClientData(message);

            foreach (var c in Clients)
            {
                if (c.ID == cd.ID)
                {
                    System.Diagnostics.Trace.WriteLine(String.Format("Updating client {0} (ID: {1})", c.Name, c.ID));
                    c.ParseMessage(message);
                    return;
                }
            }

            System.Diagnostics.Trace.WriteLine(String.Format("Adding client {0} (ID: {1})", cd.Name, cd.ID));
            Clients.Add(cd);
        }
Esempio n. 9
0
 public void AcceptCallBack(IAsyncResult result)
 {
     try
     {
         WorldClient _newClient = new WorldClient(_world.EndAccept(result), this);
         Out.Debug($"New socket [{_newClient.socket.RemoteEndPoint}]");
         Clients.Add(_newClient);
     }
     catch (Exception e)
     {
         if (Clients != null)
         {
             Out.Error(e.Message);
         }
     }
     _world.BeginAccept(AcceptCallBack, null);
 }
Esempio n. 10
0
        public MemoryUoW()
        {
            for (int i = 1; i <= 100; i++)
            {
                var num = i.ToString("D3");
                Clients.Add(new Client {
                    INN = "1000000" + num, Name = "Клиент " + num
                });
            }

            Users.Add(new User {
                Login = "******", Name = "Администратор", Password = "******"
            });
            Users.Add(new User {
                Login = "******", Name = "Менеджер", Password = "******"
            });
        }
Esempio n. 11
0
        /// <summary>
        /// Handles new TCP client
        /// </summary>
        /// <param name="tcpClient">TCP client</param>
        private void HandleNewClient(TcpClient tcpClient)
        {
            var stream = tcpClient?.GetStream();

            if (stream == null)
            {
                return;
            }

            var client = new Client(tcpClient);

            Clients.Add(client);

            client.OnNewMessage += m => OnNewMessage(m);
            client.StartListening();
            OnNewClient(client);
        }
        private void GetAllClientsNames()
        {
            try
            {
                rs = new Model.RentalShopEntities();

                foreach (var item in rs.Clients)
                {
                    Clients.Add(item.First_Name + " " + item.Second_Name + "(id" + item.Client_Id + ")");
                }
                OnPropertyChanged("Clients");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Esempio n. 13
0
 private void _onConnect(IAsyncResult result)
 {
     try
     {
         Socket s = BaseListener.EndAcceptSocket(result);      // Get the client socket object when it's ready
         OnConnected?.Invoke(this, new ConnectedEventArgs(s)); // Trigger the OnConnected event
         var client = new PrimnetClient(s, this)
         {
             RecieveBufferSize = DefaultRecieveBufferSize
         };                        // Initialize a client object from the accepted socket
         client.StartProcessing(); // Start waiting for data from the client
         client.OnDataAvaliable += (s_, e) => OnDataFromClient?.Invoke(s_, e);
         Clients.Add(client);      // Add the client object of the connection to the client list
         StartListening();         // Start waiting for a new connection after this one has been established
     }
     catch (Exception e) { Console.WriteLine(e); }
 }
        private async void Process(System.Net.Sockets.TcpClient client)
        {
            var clientId = _nextClientId++;

            var wsClient = new WebSocketClient(client)
            {
                Id           = clientId,
                ServerClient = true
            };

            Clients.Add(wsClient);

            OnClientConnected(wsClient);

            try
            {
                //check if it's a websocket connection
                while (client.Connected)
                {
                    if (await ProcessWebsocketUpgrade(wsClient).ConfigureAwait(false))
                    {
                        wsClient.UpgradedConnection = true;
                        break;
                    }
                    else
                    {
                        await Task.Delay(50).ConfigureAwait(false);
                    }
                }

                while (client.IsConnected())
                {
                    var messages = await wsClient.GetMessages().ConfigureAwait(false);

                    ProcessMessage(wsClient, messages);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }

            client?.Dispose();

            Clients.Remove(wsClient);
        }
Esempio n. 15
0
        public override void activate()
        {
            Clients.Clear();
            SqlConnector sql = SqlConnector.Instance();

            if (sql.IsConnected)
            {
                DataTable dt;
                sql.Select("* FROM client", out dt);
                foreach (DataRow dr in dt.Rows)
                {
                    Client client = new Client(dr);
                    client.UpdateView += activate;
                    Clients.Add(client);
                }
            }
        }
Esempio n. 16
0
        // ##########################################################################################
        /// <summary> Funkcja aktualizująca wewnętrzną strukturę listy podłączonych klientów. </summary>
        /// <param name="message"> Lista podłączonych klientów. </param>
        private void UpdateClients(string message)
        {
            if (Clients == null)
            {
                Clients = new List <string[]>();
            }
            Clients.Clear();
            Clients.Add(new string[] { 0.ToString(), srvName, ServerIP });

            foreach (string client in Tools.ReadLines(message))
            {
                string[] args = client.Split(' ');
                Clients.Add(new string[] { args[0], Tools.ConcatLines(args, 1, args.Length - 1, " "), args[args.Length - 1] });
            }

            UpdateList();
        }
Esempio n. 17
0
        private async Task ListeningLoop(CancellationToken ct)
        {
            while (!_cts.IsCancellationRequested)
            {
                while (!_listener.Pending())
                {
                    await Task.Delay(1000);
                }


                var newClient = await _listener.AcceptTcpClientAsync();

                var client = new TcpClient(newClient, this.Protocol, this.Client_OnPacketReceived);
                OnClientConnected?.Invoke(client);
                Clients.Add(client);
            }
        }
Esempio n. 18
0
        private void llCreateCustomer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var window = new FrmCreateClient();

            if (window.ShowDialog() == DialogResult.OK)
            {
                var client = window.CurrentClient;

                Clients.Add(client);

                FillClients();

                cmbCustomer.SelectedItem = client;

                window.Close();
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Listens for incoming connections and creates <see cref="ServerClient"/> objects for new connections
        /// </summary>
        private void Process()
        {
            try
            {
                _Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                if (string.IsNullOrEmpty(IpAddress))
                {
                    _Listener.Bind(new IPEndPoint(IPAddress.Any, Port));
                }
                else
                {
                    _Listener.Bind(new IPEndPoint(IPAddress.Parse(IpAddress), Port));
                }

                _Listener.Listen(10);


                Socket socket = null;

                while (Enabled)
                {
                    socket = _Listener.Accept();

                    ServerClient client = new ServerClient(socket, this);
                    Clients.Add(client);
                    client.Start();
                    Thread.Sleep(10);
                }
            }
            catch (SocketException ex)
            {
                // 0x2714 WSACancelBlock ignore this error
                if (ex.NativeErrorCode != 0x2714)
                {
                    OnSystemError(ex);
                }
            }
            catch (Exception ex)
            {
                OnSystemError(ex);
            }
            finally
            {
                Stop();
            }
        }
Esempio n. 20
0
        bool RegisterNewUsers(Update[] result)
        {
            bool registered = false;

            foreach (Update upd in result)
            {
                if (upd.Message == null || string.IsNullOrEmpty(upd.Message.Text))
                {
                    continue;
                }
                if (upd.Message.Text.Trim() == "/regme " + RegistrationCode)
                {
                    registered = true;
                    long chatId = upd.Message.Chat.Id;
                    if (Clients.Values.FirstOrDefault(c => c.ChatId.Identifier == chatId) != null)
                    {
                        ClientRegistered.Invoke(this, new TelegramClientInfoEventArgs()
                        {
                            Client = Clients.Values.FirstOrDefault(c => c.ChatId.Identifier == chatId)
                        });
                        continue;
                    }

                    TelegramClientInfo clientInfo = new TelegramClientInfo();
                    clientInfo.ChatId           = new ChatId(chatId);
                    clientInfo.ClientId         = RegistrationId;
                    clientInfo.RegistrationCode = RegistrationCode;
                    clientInfo.Enabled          = true;

                    Clients.Add(chatId, clientInfo);
                    if (ClientRegistered != null)
                    {
                        ClientRegistered.Invoke(this, new TelegramClientInfoEventArgs()
                        {
                            Client = clientInfo
                        });
                    }
                }
            }
            if (!registered)
            {
                Telemetry.Default.TrackEvent("Telegram bot not recv /regme command");
                Telemetry.Default.Flush();
            }
            return(true);
        }
Esempio n. 21
0
 private async Task ListenAsync(CancellationToken token)
 {
     while (!token.IsCancellationRequested)
     {
         try
         {
             var client = new Client(await Server.AcceptTcpClientAsync());
             Clients.Add(client);
             ReadAsync(client, token);
         }
         catch (Exception ex) when(ex is ObjectDisposedException || ex is SocketException)
         {
             // This happens when the server is stopped
             Console.WriteLine("Server stopped.");
         }
     }
 }
Esempio n. 22
0
        public override void Update()
        {
            if (Listener?.Pending() == true)
            {
                PlayersJoining.Add(new SCONClient(Listener.AcceptSocket(), this));
            }

            #region Player Filtration

            for (var i = 0; i < PlayersToAdd.Count; i++)
            {
                var playerToAdd = PlayersToAdd[i];

                Clients.Add(playerToAdd);
                PlayersToAdd.Remove(playerToAdd);
            }

            for (var i = 0; i < PlayersToRemove.Count; i++)
            {
                var playerToRemove = PlayersToRemove[i];

                Clients.Remove(playerToRemove);
                PlayersJoining.Remove(playerToRemove);
                PlayersToRemove.Remove(playerToRemove);

                playerToRemove.Dispose();
            }

            #endregion Player Filtration

            #region Player Updating

            // Update actual players
            for (var i = Clients.Count - 1; i >= 0; i--)
            {
                Clients[i]?.Update();
            }

            // Update joining players
            for (var i = PlayersJoining.Count - 1; i >= 0; i--)
            {
                PlayersJoining[i]?.Update();
            }

            #endregion Player Updating
        }
Esempio n. 23
0
        public IRestClient GetClient(string baseUrl)
        {
            if (string.IsNullOrEmpty(baseUrl))
            {
                throw new ArgumentNullException(nameof(baseUrl));
            }

            lock (Clients)
            {
                if (!Clients.Any(c => c.BaseUrl.Equals(baseUrl)))
                {
                    Clients.Add(new RestSharpClient(baseUrl));
                }
            }

            return(Clients.Where(c => c.BaseUrl.Equals(baseUrl)).Single());
        }
Esempio n. 24
0
        private void Listening()
        {
            IsListening = true;
            while (IsListening && Listener != null)
            {
                bool pending = false;
                try
                {
                    pending = Listener.Pending();
                }
                catch
                {
                    pending = false;
                }


                if (pending)
                {
                    TcpClient client = null;
                    try
                    {
                        client = Listener.AcceptTcpClient();
                    }
                    catch
                    {
                        break;
                    }

                    if (client != null)
                    {
                        ConnectedClient newClient = new ConnectedClient(client);
                        Clients.Add(newClient);
                        newClient.StartListening();
                        newClient.OnNewResponseFromClient += newClient_OnNewResponseFromClient;
                    }
                }

                // detecter les déco :
                List <ConnectedClient> clients2BeRemoved = new List <ConnectedClient>(Clients.Where(x => !x.TcpClient.Connected).ToList());
                foreach (ConnectedClient client in clients2BeRemoved)
                {
                    Clients.Remove(client);
                }
            }
        }
Esempio n. 25
0
        public static Dictionary <string, Beer> Cache()
        {
            if (!Clients.Contains(DuffBreweryClientId))
            {
                Clients.Add(DuffBreweryClientId);
            }

            foreach (var client in Clients)
            {
                Add(client, 1, 100, "Duff", "Lager");
                Add(client, 2, 50, "Duff Light", "Lager");
                Add(client, 3, 10, "Duff Dry", "Lager");
                Add(client, 4, 30, "Duff Stout", "Stout");
                Add(client, 5, 30, "Raseberry Duff", "IPA");
                Add(client, 6, 30, "Pawtucket Patriot Ale", "Pale Ale");
            }
            return(_inventoryData as Dictionary <string, Beer>);
        }
Esempio n. 26
0
        public async Task <int> AddClient(string name, string email)
        {
            var found = await Clients.Where(c => c.Email == email).FirstOrDefaultAsync();

            if (found == null)
            {
                Client c = new Client()
                {
                    Name = name, Email = email
                };
                Clients.Add(c);

                await SaveChangesAsync();

                return(c.ClientId);
            }
            return(found.ClientId);
        }
Esempio n. 27
0
 public void GetID(string id)
 {
     //ObservableCollection<Jewelry> jewelries = new ObservableCollection<Jewelry>();
     //foreach()
     Clients.Clear();
     try
     {
         Client[] cl = AllClients.Where(i => i.ID == long.Parse(id)).ToArray <Client>();
         foreach (Client c in cl)
         {
             Clients.Add(c);
         }
     }
     catch (FormatException e)
     {
         GetAllPerson();
     }
 }
Esempio n. 28
0
        private void OnClientConnect(CCC_Player player)
        {
            PlayerData p = ConvertPlayerData(player);

            // This code is required because it is not possible to edit
            // an ObservableCollection outside the UI thread.
            if (Application.Current != null)
            {
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate()
                                                      { Clients.Add(p); });
            }
            else
            {
                Clients.Add(p);
            }

            PlayerConnected(p);
        }
Esempio n. 29
0
 protected void AcceptConnectionAsync(IAsyncResult result)
 {
     try
     {
         if (Listener == null || result == null)
         {
             return;                                     // This happens sometimes on shut down, it's weird
         }
         var tcpClient = Listener.EndAcceptTcpClient(result);
         var client    = new MinecraftClient(tcpClient, this);
         lock (NetworkLock)
         {
             Clients.Add(client);
         }
         Listener.BeginAcceptTcpClient(AcceptConnectionAsync, null);
     }
     catch { } // TODO: Investigate this more deeply
 }
Esempio n. 30
0
        private async Task Run()
        {
            Listener.Start();

            while (!Token.IsCancellationRequested)
            {
                try
                {
                    var client = await Listener.AcceptTcpClientAsync().WaitAsync(Token);

                    Clients.Add(client);
                }
                catch (ObjectDisposedException)
                {
                    return;
                }
            }
        }