internal void Radio(C2CRadioPackage radioPkg) { //配置请求包 ServerRequestPackage reqtPkg = new ServerRequestPackage(true); IRadioMessageRequest reqtInterface = reqtPkg.Active_RadioMessageRequest(); reqtInterface.RadioMessage(radioPkg.Group.Token, radioPkg); BinTransferLayer binProcessor = _mclLayerProcessor.BinTransferProcessor; ServerReplyPackage replyPkg = null; try { replyPkg = binProcessor.SynSendMessage(reqtPkg, 100000); } catch (System.Exception ex) { throw new RadioGroupExcetion(ex.ToString()); } IRadioReply replyInterface = replyPkg.Active_RadioGroupReply(); bool ret; string errorDetail; replyInterface.RadioRet(out ret, out errorDetail); if (true == ret) { //nothing to do } else { throw new RadioGroupExcetion(errorDetail); } }
internal void RadioTransferMessageRecived(C2CRadioPackage c2cRadioPkg) { if (!c2cRadioPkg.OutsideMessage.IsEmpty) { //outside notify this.CoRemotRadioRecived_OutsideNotify(c2cRadioPkg.OutsideMessage); } else { //消息模块数据包 if (null != (c2cRadioPkg as C2CMessageRadioPackage)) { mMiddlewareMessenger.MessagePackageIncoming(c2cRadioPkg as C2CMessageRadioPackage); } } }
private void __CoAsynRadioRunning(GroupComunicatePackage communicator) { RadioPackage radioPkg = new RadioPackage(communicator.TargetDevice, communicator.CommunicationName, communicator.ParamPackage.ParamDefalutValues); C2CRadioPackage c2cRadioPkg = new C2CRadioPackage(communicator.TargetDevice, "outside radio message", null); c2cRadioPkg.OutsideMessage = radioPkg; try { _groupCommunicateProcessor.Radio(c2cRadioPkg); } catch (System.Exception ex) { this.CoRadioErrorRecived_OutsideNotify(communicator, new RadioErrorExcetion(ex.ToString())); } }
/// <summary> /// 对二进制段做反序列化 /// </summary> /// <param name="bytes">目标二进制字段</param> /// <returns>反序列化结果</returns> public new RadioPackage DeserializeMessage(byte[] bytes) { if ((null == bytes) || (0 == bytes.Length)) { throw new Exception("Bin数据不存在或为空"); } byte bytOpjTypeCodec = bytes[0]; switch (bytOpjTypeCodec) { case (byte)SerializObjectType.RadioPackage: { try { byte[] bytObjContent = new byte[bytes.Length - 1]; Buffer.BlockCopy(bytes, 1, bytObjContent, 0, bytObjContent.Length); CCCommunicateClass.Seria_RadioPackage serializeFormatPkg = null; RadioPackage ret = new RadioPackage(); { using (MemoryStream m = new MemoryStream(bytObjContent)) { CJNet_SerializeTool deSerializeTool = new CJNet_SerializeTool(); serializeFormatPkg = deSerializeTool.Deserialize(m, null, typeof(CCCommunicateClass.Seria_RadioPackage)) as CCCommunicateClass.Seria_RadioPackage; } } ret.ParseSerializeData(serializeFormatPkg); return(ret); } catch (System.Exception ex) { throw new Exception("针对Bin数据尝试反序列失败,请检验数据格式: " + ex.ToString()); } } case (byte)SerializObjectType.C2CRadioPackage: { try { byte[] bytObjContent = new byte[bytes.Length - 1]; Buffer.BlockCopy(bytes, 1, bytObjContent, 0, bytObjContent.Length); CCCommunicateClass.Seria_C2CRadioPackage serializeFormatPkg = null; C2CRadioPackage ret = new C2CRadioPackage(); using (MemoryStream m = new MemoryStream(bytObjContent)) { CJNet_SerializeTool deSerializeTool = new CJNet_SerializeTool(); serializeFormatPkg = deSerializeTool.Deserialize(m, null, typeof(CCCommunicateClass.Seria_C2CRadioPackage)) as CCCommunicateClass.Seria_C2CRadioPackage; } ret.ParseSerializeData(serializeFormatPkg); return(ret); } catch (System.Exception ex) { throw new Exception("针对Bin数据尝试反序列失败,请检验数据格式: " + ex.ToString()); } } case (byte)SerializObjectType.C2CMessageRadioPackage: { try { byte[] bytObjContent = new byte[bytes.Length - 1]; Buffer.BlockCopy(bytes, 1, bytObjContent, 0, bytObjContent.Length); CCCommunicateClass.Seria_C2CMessageRadioPackage serializeFormatPkg = null; using (MemoryStream m = new MemoryStream(bytObjContent)) { CJNet_SerializeTool deSerializeTool = new CJNet_SerializeTool(); serializeFormatPkg = deSerializeTool.Deserialize(m, null, typeof(CCCommunicateClass.Seria_C2CMessageRadioPackage)) as CCCommunicateClass.Seria_C2CMessageRadioPackage; } C2CMessageRadioPackage ret = new C2CMessageRadioPackage(); ret.ParseSerializeData(serializeFormatPkg); return(ret); } catch (System.Exception ex) { throw new Exception("针对Bin数据尝试反序列失败,请检验数据格式: " + ex.ToString()); } } default: { throw new NotImplementedException("二进制数据指向无法识别的类型"); } } }