Esempio n. 1
0
 public void TreeItem_PreviewMouseLeftButtonDown(object sender, RoutedEventArgs e)
 {
     foreach (var ser in ServersList)
     {
         ser.IsSelected = false;
         foreach (var tmp in ser.ClientsList)
         {
             tmp.IsSelected = false;
         }
     }
     if (sender is ServersInfo)
     {
         SelectServer            = sender as ServersInfo;
         SelectServer.IsSelected = true;
         if (SelectServer.ClientsList.Count > 0)
         {
             SelectServer.SelectClient = SelectServer.ClientsList[0];
         }
     }
     else if (sender is ClientsInfo)
     {
         ClientsInfo client = sender as ClientsInfo;
         SelectServer = client.ParentServer;
         SelectServer.SelectClient            = client;
         SelectServer.SelectClient.IsSelected = true;
     }
 }
Esempio n. 2
0
        void TcpServer_DataReceived(object sender, AsyncEventArgs e)
        {
            TCPClientState client     = e._state as TCPClientState;
            string         remote     = client.TcpClient.Client.RemoteEndPoint.ToString();
            string         receStr    = Encoding.Default.GetString(client.Buffer, 0, client.BufferLength);
            ClientsInfo    clientinfo = null;

            foreach (var ser in ServersList)
            {
                foreach (var cle in ser.ClientsList)
                {
                    if (cle.IpEndPort.ToString() == remote)
                    {
                        clientinfo       = cle;
                        cle.ReceiveText += receStr;
                        break;
                    }
                }
            }

            string data = INIOperation.INIGetStringValue(path, section, receStr, null);

            if (data == null)
            {
                return;
            }
            byte[] aryData = Encoding.ASCII.GetBytes(data);
            clientinfo.ParentServer.TcpServer.Send(client, aryData);
            clientinfo.SendText += data;
        }
Esempio n. 3
0
        void TcpServer_ClientConnected(object sender, AsyncEventArgs e)
        {
            AsyncTCPServer server = sender as AsyncTCPServer;
            int            temp   = ServersList.ToList <ServersInfo>().FindIndex(ex => (ex.IPAddr.ToString() == server.Address.ToString() && ex.Port == server.Port));

            if (temp == -1)//列表中没找到服务器
            {
                return;
            }
            TCPClientState client     = e._state as TCPClientState;
            ClientsInfo    clientinfo = new ClientsInfo();

            clientinfo.IpEndPort    = client.TcpClient.Client.RemoteEndPoint;
            clientinfo.ClientState  = client;
            clientinfo.ParentServer = ServersList[temp];
            App.Current.Dispatcher.Invoke((System.Action)(() =>
            {
                ServersList[temp].ClientsList.Add(clientinfo);
                foreach (var ser in ServersList)
                {
                    ser.IsSelected = false;
                    foreach (var tmp in ser.ClientsList)
                    {
                        tmp.IsSelected = false;
                    }
                }
                SelectServer = ServersList[temp];
                SelectServer.SelectClient            = clientinfo;
                SelectServer.SelectClient.IsSelected = true;
                IsHaveClent = true;
            }));
        }