/// <summary> /// ���յ������ݵĴ��� /// </summary> private void DealData() { // if (buf.Length > 0) //��������Ҫ���� { CommHead chio = new CommHead(buf, (int) buf.Position); if (chio.IsValid()) { LastReceivedTime = DateTime.Now; if (chio.DataLen > 0) //��Ч���� { adm.AddData(this, chio.GetData(), chio.DataLen); //�ɴ������� } else //���ڲ���Ϣ { switch ((JhCommMessages) chio.WParam) { case JhCommMessages.Disconnected: //�Է���Ҫ�Ͽ�������Ϣ Close(); break; case JhCommMessages.ConnectCheck: if (CheckTimeout.Ticks != chio.DWParam) { CheckTimeout = new TimeSpan(chio.DWParam); } ConnectCheck = true; break; case JhCommMessages.StopCheck: ConnectCheck = false; break; case JhCommMessages.ConnectSignal: if (CheckTimeout.Ticks != chio.DWParam) { CheckTimeout = new TimeSpan(chio.DWParam); } break; default: break; } } buf.Position = 0; chio.GetLeftData(ref buf); //ʣ��δ���������� } } }
/// <summary> /// ����������Ϣ /// </summary> /// <param name="message"></param> private void SendMessage(JhCommMessages message, Int32 parm) { CommHead ch = new CommHead(); ch.WParam = (short) message; ch.DWParam = parm; Client.GetStream().Write(ch.ToBytes(), 0, 16); }
/// <summary> /// �������� /// </summary> /// <param name="data"></param> /// <returns></returns> public void Send(byte[] data) { if (Connected == true) { CommHead ch = new CommHead(); ch.WParam = (short) JhCommMessages.DataTransfer; ch.Add(data); client.GetStream().Write(ch.ToBytes(), 0, ch.Length); } else { MessageBox.Show("��δ�������ӻ��������Ѿ��Ͽ�!"); } }