/// <summary> /// 开始发送数据 /// </summary> /// <param name="Opcode">操作码</param> /// <param name="Subcode">子操作</param> /// <param name="value">参数</param> public void StartSend(int Opcode, int Subcode, object value) { SocketMsg mgr = new SocketMsg(Opcode, Subcode, value); byte[] data = EncodeTool.EncodeSocketMgr(mgr); byte[] packet = EncodeTool.EncodeMessage(data);//构造数据包 StartSend(packet); }
private void processReceive() { isReceiveProcessing = true; byte[] data = EncodeTool.DecodeMessage(ref clientdataCache); if (data == null) { isReceiveProcessing = false; return; } SocketMsg value = EncodeTool.DeCodeSocketMgr(data); //将解析后的数据转化为具体的类型 //回调给上层 if (ReceiveComplatedEvent != null) { ReceiveComplatedEvent(this, value); } //递归处理数据包 processReceive(); }