/// <summary>
        /// Initializes a new instance of the ClientViewModel class.
        /// </summary>
        public ClientViewModel(ClientModel client)
        {
            Client = client;
            client.Name = "Client";

            Messenger.Default.Register<RemoveClientMessage>(this, (message) =>
            {
                if (message.Client.RemoteEndPoint == Client.RemoteEndPoint)
                {
                    if (Client.ClientSocketState == ChildSocketState.Connected)
                    {
                        SimpleIoc.Default.GetInstance<ServerService>().Disconnect(Client);
                    }
                    SimpleIoc.Default.Unregister(this);
                }
            });
            SimpleIoc.Default.Register(() => this, client.RemoteEndPoint);
        }
Example #2
0
 public void Disconnect(ClientModel client)
 {
     SimpleServerChildTcpSocket[] children = new SimpleServerChildTcpSocket[Server.ChildSockets.Keys.Count];
     Server.ChildSockets.Keys.CopyTo(children, 0);
     foreach (SimpleServerChildTcpSocket child in children)
     {
         if (child.RemoteEndPoint.ToString().Equals(client.RemoteEndPoint))
         {
             try
             {
                 child.ShutdownAsync();
                 Server.ChildSockets[child] = ChildSocketState.Disconnecting;
             }
             catch (Exception ex)
             {
                 ConsoleService.Write("Child Socket error disconnecting from " + child.RemoteEndPoint + ": [" + ex.GetType().Name + "] " + ex.Message);
                 ResetChildSocket(child);
             }
         }
     }
 }
 public AddClientMessage(ClientModel client)
 {
     Client = client;
 }
 public OnClientAddedEventArgs(ClientModel client)
 {
     Client = client;
 }
 public RemoveClientMessage(ClientModel client, Action<bool> feedback)
 {
     Client = client;
     Feedback = feedback;
 }
 public RemoveClientMessage(ClientModel client)
 {
     Client = client;
 }
 public OnClientRemovedEventArgs(ClientModel client)
 {
     Client = client;
 }