/// <summary>
 /// ��������
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Send(JhClient client, string data)
 {
     if (client != null)
     {
         byte[] dt = Encoding.Default.GetBytes(data);
         client.Send(dt);
     }
 }
Пример #2
0
 public CommData(JhClient client, MemoryStream stream, int len, CommDataMgr dm)
 {
     jhClient = client;
     Data = new MemoryStream();
     stream.WriteTo(Data);
     dataLen = len;
     adm = dm;
 }
 /// <summary>
 /// ���յ��µ������ύ
 /// </summary>
 /// <param name="client">�ͻ�������</param>
 /// <param name="s">������</param>
 public void AddData(JhClient client, MemoryStream s, int len)
 {
     CommData cd = new CommData(client, s, len, this);
     lock (this)
     {
         aData.Add(cd);
     }
 }
 /// <summary>
 /// �ͻ������߳�
 /// </summary>
 private void ListenThread()
 {
     try
     {
         while (status.Status == JhThreadStatus.Running)
         {
             if (server.Pending() == true)
             {
                 TcpClient client = server.AcceptTcpClient(); //���������Ӻ󴴽��ͻ���
                 JhClient jhClient = new JhClient(adm, client);
                 jhClient.ID = clientindex--;
                 SetClient(jhClient);
                 jhClient.Connected = true;
             }
             Thread.Sleep(100);
         }
     }
     catch (ObjectDisposedException e2)
     {
         MessageBox.Show(e2.Message);
     }
     catch (InvalidOperationException e1)
     {
         MessageBox.Show(e1.Message);
     }
     catch (Exception e3)
     {
         MessageBox.Show(e3.Message);
     }
     finally
     {
         lock (this)
         {
             status.Status = JhThreadStatus.Exit;
         }
         Console.WriteLine("JH tcp listenor exited");
     }
 }
 /// <summary>
 /// ���ÿͻ��˶���
 /// </summary>
 /// <param name="client"></param>
 public void SetClient(JhClient client)
 {
     int i;
     for (i = 0; i < clients.Count; ++i)
     {
         if (((JhClient) clients[i]).ID == client.ID)
         {
             break;
         }
     }
     clients[i] = client;
 }