Пример #1
0
        public ActionResult RemoveConfirm(int userid)
        {
            RemoveClient removeClient = new RemoveClient();

            removeClient.DoWork(userid);
            return(RedirectToAction("Get"));
        }
    private void disconnectAvatarFromClients(RemoveClient clientToRemove)
    {
        for (int i = 0; i < _clients.Count; i++)
        {
            LobbyClient client = _clients[i];

            sendObject(client.TcpClient, clientToRemove);
        }
    }
Пример #3
0
        /// <summary>
        /// Handles the client.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="stream">The stream.</param>
        public void HandleClient(TcpClient client, NetworkStream stream)
        {
            m_logging.Log("start listening to new client...", Logging.Modal.MessageTypeEnum.INFO);
            new Task(() =>
            {
                StreamReader reader = new StreamReader(stream);
                StreamWriter writer = new StreamWriter(stream);
                while (true)
                {
                    try
                    {
                        bool res;
                        string commandLine = reader.ReadLine();
                        while (reader.Peek() > 0)
                        {
                            commandLine += reader.ReadLine();
                        }
                        if (commandLine != null)
                        {
                            CommandRecievedEventArgs command = JsonConvert.DeserializeObject <CommandRecievedEventArgs>(commandLine);

                            if (command.CommandID.Equals((int)CommandEnum.CloseGui))
                            {
                                string[] args = { JsonConvert.SerializeObject(client) };
                                CommandRecievedEventArgs closeCommand = new CommandRecievedEventArgs((int)CommandEnum.CloseGui, args, "");
                                m_controller.ExecuteCommand(closeCommand.CommandID, closeCommand.Args, out res);
                                m_logging.Log("Client disconnected", Logging.Modal.MessageTypeEnum.WARNING);
                                break;
                            }
                            string result = m_controller.ExecuteCommand(command.CommandID, command.Args, out res);
                            try
                            {
                                //  Thread.Sleep(1000);
                                mtx.WaitOne();
                                writer.WriteLine(result);
                                writer.Flush();
                                mtx.ReleaseMutex();
                            } catch (Exception e)
                            {
                                m_logging.Log("Client disconnected", Logging.Modal.MessageTypeEnum.WARNING);
                                RemoveClient?.Invoke(client);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        return;
                    }
                }
            }).Start();
        }
Пример #4
0
        private void Remove(WebNotifyConnection client)
        {
            try
            {
                connections.Remove(client);
                client?.Dispose();
            }
            catch (Exception ex)
            {
                Helper.OnException(ex);
            }

            RemoveClient?.Invoke(this, new WebNotifyEventArgs(client));
        }
        public async Task <IHttpActionResult> DeleteClient([FromBody] RemoveClient model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var findClient = await DB.ClientsTable.SingleOrDefaultAsync(x => x.Id == model.ClientId);

            if (findClient != null)
            {
                DB.ClientsTable.Remove(findClient);
                await DB.SaveChangesAsync();
            }
            return(Ok());
        }
    private void removeFaultyClients()
    {
        for (int i = 0; i < _clients.Count; i++)
        {
            LobbyClient client = _clients[i];

            //remove faulty clients
            if (!client.TcpClient.Connected)
            {
                Console.WriteLine("CLIENT " + client.id + " DISCONNECTED");

                RemoveClient clientToRemove = new RemoveClient();
                clientToRemove.SetParameters(client.id);

                _clients.RemoveAt(i);

                disconnectAvatarFromClients(clientToRemove);

                continue;
            }
        }
    }
Пример #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public void Handle(RemoveClient message)
 {
     m_clientById.Remove(message.Client.ClientId);
     m_log.Info("remove client : {0}", message.Client.ClientId);
 }
Пример #8
0
 private void OnRemoveClient(SocketConnection sender)
 {
     RemoveClient?.Invoke(sender);
 }
Пример #9
0
 /// <summary>
 /// Delete the role.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns>IList&lt;IEvent&gt;.</returns>
 /// <exception cref="ClientNotFoundException">Id</exception>
 /// <exception cref="ClientConcurrencyFailureException"></exception>
 private IList <IEvent> Handle(RemoveClient command)
 {
     CheckConcurrencyStamp(command.ConcurrencyCheckStamp);
     return(new[] { new ClientRemoved(Id, command.UserId, command.CorrelationId) });
 }