///<summary> Reads this HLApublishObjectClassAttributesMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLApublishObjectClassAttributesMessage decodedValue; if (!(msg is HLApublishObjectClassAttributesMessage)) { decodedValue = new HLApublishObjectClassAttributesMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLApublishObjectClassAttributesMessage; } object tmp = decodedValue; decodedValue = base.Deserialize(reader, ref tmp) as HLApublishObjectClassAttributesMessage; try { byte[] objectClassByteArray = reader.ReadHLAopaqueData(); decodedValue.HLAobjectClass = objectClassFactory.Decode(objectClassByteArray, 0); decodedValue.HLAattributeList = attributeHandleSetFactory.Create(); int count = reader.ReadHLAinteger32BE(); for (int i = 0; i < count; i++) { IAttributeHandle attributeHandle = attributeHandleFactory.Decode(reader.ReadHLAopaqueData(), 0); decodedValue.HLAattributeList.Add(attributeHandle); } /* * decodedValue.HLAobjectClass = new byte[reader.ReadHLAinteger32BE()]; * * for (int i = 0; i < decodedValue.HLAobjectClass.Length; i++) * { * decodedValue.HLAobjectClass[i] = reader.ReadHLAoctet(); * } * decodedValue.HLAattributeList = new byte[reader.ReadHLAinteger32BE()][]; * * for (int i = 0; i < decodedValue.HLAattributeList.Length; i++) * { * decodedValue.HLAattributeList[i] = new byte[reader.ReadHLAinteger32BE()]; * * for (int j = 0; j < decodedValue.HLAattributeList[i].Length; j++) * { * decodedValue.HLAattributeList[i][j] = reader.ReadHLAoctet(); * } * } */ } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
/// <summary>Notifies the listener of a received interaction.</summary> /// <param name="msg"> the message of the received interaction</param> public void ReceiveInteraction(BaseInteractionMessage msg) { try { if (msg is BoxInHouseMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is ITimeManagementObjectModelInteractionListener) { (il as ITimeManagementObjectModelInteractionListener).OnReceiveBoxInHouse(msg as BoxInHouseMessage); } else { il.ReceiveInteraction(msg); } } } else { foreach (IInteractionListener il in manager.InteractionListeners) { il.ReceiveInteraction(msg); } } } catch (System.IO.IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
/// <summary> /// Sends an interaction. /// </summary> /// <param name="msg">the message or interaction to send /// </param> public virtual void SendInteraction(TransportationType transport, BaseInteractionMessage msg) { if (!channel2TransportationMap.ContainsKey(transport)) { throw new Exception("Transport unknown"); } foreach (KeyValuePair <TransportationType, ChannelType> keyValue in channel2TransportationMap) { if (keyValue.Key.Equals(transport)) { try { ChannelType channelType = keyValue.Value; if (channelType.Equals(ChannelType.TCP)) { SendRealiableInteraction(channelType, msg); } else { SendBestEffortInteraction(channelType, msg); } } catch (Exception e) { //TODO. What should I do when the channel is remotly closed and lost??. //TODO. if (log.IsWarnEnabled) { log.Warn("Error sending interaction: " + e.Message); } } } } }
/// <summary>Notifies the listener of a received interaction.</summary> /// <param name="msg"> the message of the received interaction</param> public void ReceiveInteraction(BaseInteractionMessage msg) { try { /* * if (msg is CommunicationMessage) * { * foreach (IInteractionListener il in manager.InteractionListeners) * { * if (il is IHelloWorldObjectModelInteractionListener) * (il as IHelloWorldObjectModelInteractionListener).OnReceiveCommunication(msg as CommunicationMessage); * else * il.ReceiveInteraction(msg); * } * } * else */ foreach (IInteractionListener il in manager.InteractionListeners) { il.ReceiveInteraction(msg); } } catch (System.IO.IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
///<summary> Reads this HLAupdateAttributeValuesBestEffortWithTimeMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLAupdateAttributeValuesBestEffortWithTimeMessage decodedValue; if (!(msg is HLAupdateAttributeValuesBestEffortWithTimeMessage)) { decodedValue = new HLAupdateAttributeValuesBestEffortWithTimeMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.CopyTo(baseMsg); //decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; //decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; //decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAupdateAttributeValuesBestEffortWithTimeMessage; } object tmp = decodedValue; decodedValue = base.Deserialize(reader, ref tmp) as HLAupdateAttributeValuesBestEffortWithTimeMessage; //decodedValue.LogicalTime = reader.ReadHLAopaqueData(); return(decodedValue); }
public override void ReceiveInteraction(BaseInteractionMessage msg) { try { if (msg is HLAregisterObjectInstanceMessage) { this.OnReceiveHLAregisterObjectInstance(msg as HLAregisterObjectInstanceMessage); } else if (msg is HLAregisterObjectInstanceWithTimeMessage) { this.OnReceiveHLAregisterObjectInstanceWithTime(msg as HLAregisterObjectInstanceWithTimeMessage); } else if (msg is HLAupdateAttributeValuesBestEffortWithTimeMessage) { this.OnReceiveHLAupdateAttributeValuesBestEffortWithTime(msg as HLAupdateAttributeValuesBestEffortWithTimeMessage); } else if (msg is HLAupdateAttributeValuesReliableWithTimeMessage) { this.OnReceiveHLAupdateAttributeValuesReliableWithTime(msg as HLAupdateAttributeValuesReliableWithTimeMessage); } else if (msg is HLAupdateAttributeValuesBestEffortMessage) { this.OnReceiveHLAupdateAttributeValuesBestEffort(msg as HLAupdateAttributeValuesBestEffortMessage); } else if (msg is HLAupdateAttributeValuesReliableMessage) { this.OnReceiveHLAupdateAttributeValuesReliable(msg as HLAupdateAttributeValuesReliableMessage); } } catch (System.IO.IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
/// <summary> /// Sends an interaction with reliable (TCP) transportation. /// </summary> /// <param name="msg">the interaction message /// </param> /// <exception cref="InteractionClassNotPublished"> if the interaction class is not published /// </exception> /// <exception cref="InteractionClassNotDefined"> if the interaction class is undefined /// </exception> /// <exception cref="InteractionParameterNotDefined"> if one of the parameters is undefined /// </exception> /// <exception cref="FederateNotExecutionMember"> if the federate is not a member of an execution /// </exception> /// <exception cref="SaveInProgress"> if a save operation is in progress /// </exception> /// <exception cref="RestoreInProgress"> if a restore operation is in progress /// </exception> /// <exception cref="RTIinternalError"> if an internal error occurred in the /// run-time infrastructure /// </exception> public virtual void SendRealiableInteraction(ChannelType channelType, BaseInteractionMessage msg) { /* * if (log.IsInfoEnabled) * log.Info("On " + System.Reflection.MethodBase.GetCurrentMethod()); */ IList <IMessageChannel> list = channelManager.ChannelsList(channelType); if (list != null) { foreach (StreamMessageChannel messageChannel in list) { try { SendRealiableInteraction(messageChannel, msg); } catch (Exception e) { //TODO. What should I do when the channel is remotly closed and lost??. //TODO. if (log.IsWarnEnabled) { log.Warn("Error sending interaction: " + e.Message); } } } } }
/// <summary>Notifies the listener of a received interaction.</summary> /// <param name="msg"> the message of the received interaction</param> public void ReceiveInteraction(BaseInteractionMessage msg) { try { if (msg is CommunicationMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IExternalSamplesObjectModelInteractionListener) { (il as IExternalSamplesObjectModelInteractionListener).OnReceiveCommunication(msg as CommunicationMessage); } else { il.ReceiveInteraction(msg); } } } else { foreach (IInteractionListener il in manager.InteractionListeners) { il.ReceiveInteraction(msg); } } } catch (System.IO.IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
/// <summary> /// Sends an interaction with best-effort (UDP) transportation. /// </summary> /// <param name="msg">the interaction message /// </param> /// <exception cref="InteractionClassNotPublished"> if the interaction class is not published /// </exception> /// <exception cref="InteractionClassNotDefined"> if the interaction class is undefined /// </exception> /// <exception cref="InteractionParameterNotDefined"> if one of the parameters is undefined /// </exception> /// <exception cref="FederateNotExecutionMember"> if the federate is not a member of an execution /// </exception> /// <exception cref="SaveInProgress"> if a save operation is in progress /// </exception> /// <exception cref="RestoreInProgress"> if a restore operation is in progress /// </exception> /// <exception cref="RTIinternalError"> if an internal error occurred in the /// run-time infrastructure /// </exception> public virtual void SendBestEffortInteraction(ChannelType channelType, BaseInteractionMessage msg) { /* * if (log.IsInfoEnabled) * log.Info("On " + System.Reflection.MethodBase.GetCurrentMethod()); */ try { System.IO.MemoryStream bufferStream = new System.IO.MemoryStream(); serializer.Serialize(bufferStream, msg); byte[] buffer = bufferStream.ToArray(); IList <IMessageChannel> list = channelManager.ChannelsList(channelType); if (list != null) { foreach (IMessageChannel messageChannel in list) { SendBestEffortInteraction(messageChannel, buffer); } } } catch (System.Exception e) { throw new RTIinternalError(e.Message); } }
///<summary> Reads this BoxInHouseMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { BoxInHouseMessage decodedValue; if (!(msg is BoxInHouseMessage)) { decodedValue = new BoxInHouseMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as BoxInHouseMessage; } object tmp = decodedValue; try { decodedValue = base.Deserialize(reader, ref tmp) as BoxInHouseMessage; decodedValue.Time = reader.ReadHLAopaqueData(); } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
/* * if (rti.State != null) * { * * // 1. Add a callback that notifies the box will arrive * ObjectInstanceDescriptor oid = rti.descriptorManager.GetObjectInstanceDescriptor(home.InstanceHandle); * IObjectClassHandle och = oid.ClassHandle; * ObjectClassDescriptor ocd = rti.descriptorManager.GetObjectClassDescriptor(och); * * HLAattributeHandleValuePair[] handleValuePairList = new HLAattributeHandleValuePair[1]; * handleValuePairList[0] = new HLAattributeHandleValuePair(); * handleValuePairList[0].AttributeHandle = ((XRTIAttributeHandle)ocd.GetAttributeDescriptor("BoxesCount").Handle).Identifier; * handleValuePairList[0].AttributeValue = 1; * * // ############################################################################### * Lrc.ReflectAttributeValuesExtCallback callback = * new Lrc.ReflectAttributeValuesExtCallback(home.OwnFederateAmbassador, * time, home.InstanceHandle, handleValuePairList, new byte[1]); * * rti.State.Add(callback); * * if (log.IsDebugEnabled) * { * log.Debug("Added callback " + callback + " for time " + time); * } * // ############################################################################### * rti.UpdateAttributeValues(home.InstanceHandle, handleValuePairList, new byte[1], time); * * // 2. Add a callback that notifies the box will leave * time = time.Add(moveActorInterval); * * handleValuePairList = new HLAattributeHandleValuePair[1]; * handleValuePairList[0] = new HLAattributeHandleValuePair(); * handleValuePairList[0].AttributeHandle = ((XRTIAttributeHandle)ocd.GetAttributeDescriptor("BoxesCount").Handle).Identifier; * handleValuePairList[0].AttributeValue = 0; * * // ############################################################################### * callback = new Lrc.ReflectAttributeValuesExtCallback(home.OwnFederateAmbassador, * time, home.InstanceHandle, handleValuePairList, new byte[1]); * * rti.State.Add(callback); * * if (log.IsDebugEnabled) * { * log.Debug("Added callback " + callback + " for time " + time); * } * // ############################################################################### * rti.UpdateAttributeValues(home.InstanceHandle, handleValuePairList, new byte[1], time); * } */ #region IInteractionListener Members public void ReceiveInteraction(BaseInteractionMessage msg) { /* * if (log.IsDebugEnabled) * log.Debug("Received BaseInteractionMessage = " + msg.ToString()); */ }
/// <summary>Notifies the federate of a received interaction.</summary> /// <param name="decodedValue"> the message of the received interaction</param> public void ReceiveInteraction(BaseInteractionMessage msg) { if (log.IsDebugEnabled) log.Debug("Read msg: " + msg); try { if (interactionDelegates.ContainsKey(msg.GetType())) { interactionDelegates[msg.GetType()](msg); } //else //{ lock (interactionListeners) { foreach (IInteractionListener il in interactionListeners) { (il as IInteractionListener).ReceiveInteraction(msg); } } //} } catch (IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
public override void ReceiveInteraction(BaseInteractionMessage msg) { if (log.IsDebugEnabled) { log.Debug("Received BaseInteractionMessage = " + msg.ToString()); } }
public virtual void SendInteraction(BaseInteractionMessage msg) { try { IParameterHandleValueMap phvm = rtiAmbassador.ParameterHandleValueMapFactory.Create(0); //rtiAmbassador.SendInteraction(decodedValue.InteractionClassHandle, phvm, decodedValue.UserSuppliedTag); } catch (System.Exception e) { throw new RTIinternalError(e.ToString()); } }
public void OnReceiveHLAGenericInteraction(BaseInteractionMessage msg) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IBootstrapObjectModelInteractionListener) { (il as IBootstrapObjectModelInteractionListener).OnReceiveHLAGenericInteraction(msg as HLAGenericInteractionMessage); } else { il.ReceiveInteraction(msg); } } }
public void DispatchInteraction(BaseInteractionMessage msg) { if (interactionsDelegates.ContainsKey(msg.FederationExecutionHandle)) { if (interactionsDelegates[msg.FederationExecutionHandle].ContainsKey(msg.GetType())) { interactionsDelegates[msg.FederationExecutionHandle][msg.GetType()](msg); } else { interactionsDelegates[msg.FederationExecutionHandle][typeof(BaseInteractionMessage)](msg); } } }
/// <summary>Notifies the listener of a received interaction.</summary> /// <param name="msg"> the message of the received interaction</param> public void ReceiveInteraction(BaseInteractionMessage msg) { try { foreach (IInteractionListener il in manager.InteractionListeners) { il.ReceiveInteraction(msg); } } catch (System.IO.IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
///<summary> Reads this HLAregisterObjectInstanceMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { /* msg2 * HLAregisterObjectInstanceMessage msg = new HLAregisterObjectInstanceMessage(); * msg.CopyTo((BaseInteractionMessage)msg2); * * try * { * msg.ObjectName = reader.ReadHLAunicodeString(); * msg.ObjectInstanceHandle = reader.ReadHLAinteger64BE(); * msg.ObjectClassHandle = reader.ReadHLAinteger64BE(); * } * catch (IOException ioe) * { * throw new RTIinternalError(ioe.ToString()); * } * return msg; */ HLAregisterObjectInstanceMessage decodedValue; if (!(msg is HLAregisterObjectInstanceMessage)) { decodedValue = new HLAregisterObjectInstanceMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.CopyTo(baseMsg); //decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; //decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; //decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAregisterObjectInstanceMessage; } object tmp = decodedValue; try { decodedValue = base.Deserialize(reader, ref tmp) as HLAregisterObjectInstanceMessage; decodedValue.ObjectName = reader.ReadHLAunicodeString(); decodedValue.ObjectInstanceHandle = reader.ReadHLAinteger64BE(); decodedValue.ObjectClassHandle = reader.ReadHLAinteger64BE(); } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
/// <summary> /// Sends an interaction. /// </summary> /// <param name="decodedValue">the message or interaction to send /// </param> public virtual void SendInteraction(BaseInteractionMessage msg) { TransportationType transport = interactionChannelMap[msg.GetType()]; // If transport is null, then we send it directly to // our listeners if (transport == null) { ReceiveInteraction(msg); } else { //msg.InteractionClassHandle = ((XRTIInteractionClassHandle)interactionClassDescriptorMap[msg.GetType()].Handle).Identifier; msg.InteractionClassHandle = SerializerManager.GetHandle(msg.GetType()); SendInteraction(transport, msg); } }
///<summary> Reads this HLAinteractionRootMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLAinteractionRootMessage decodedValue; if (!(msg is HLAinteractionRootMessage)) { decodedValue = new HLAinteractionRootMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAinteractionRootMessage; } return(decodedValue); }
///<summary> Reads this HLAsubscribeInteractionClassMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLAsubscribeInteractionClassMessage decodedValue; if (!(msg is HLAsubscribeInteractionClassMessage)) { decodedValue = new HLAsubscribeInteractionClassMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAsubscribeInteractionClassMessage; } object tmp = decodedValue; decodedValue = base.Deserialize(reader, ref tmp) as HLAsubscribeInteractionClassMessage; try { byte[] interactionClassHandleByteArray = reader.ReadHLAopaqueData(); decodedValue.HLAinteractionClass = interactionClassHandleFactory.Decode(interactionClassHandleByteArray, 0); decodedValue.HLAactive = reader.ReadHLAboolean(); /* * decodedValue.HLAinteractionClass = new byte[reader.ReadHLAinteger32BE()]; * * for (int i = 0; i < decodedValue.HLAinteractionClass.Length; i++) * { * decodedValue.HLAinteractionClass[i] = reader.ReadHLAoctet(); * } * decodedValue.HLAactive = reader.ReadHLAboolean(); */ } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
private void SendBestEffortInteraction(IMessageChannel messageChannel, BaseInteractionMessage msg) { /* * if (log.IsInfoEnabled) * log.Info("On " + System.Reflection.MethodBase.GetCurrentMethod()); */ try { System.IO.MemoryStream bufferStream = new System.IO.MemoryStream(); serializer.Serialize(bufferStream, msg); byte[] buffer = bufferStream.ToArray(); SendBestEffortInteraction(messageChannel, buffer); } catch (System.Exception e) { throw new RTIinternalError(e.Message); } }
///<summary> Reads this HLAupdateAttributeValuesMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLAupdateAttributeValuesMessage decodedValue; if (!(msg is HLAupdateAttributeValuesMessage)) { decodedValue = new HLAupdateAttributeValuesMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.CopyTo(baseMsg); //decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; //decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; //decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAupdateAttributeValuesMessage; } object tmp = decodedValue; try { decodedValue = base.Deserialize(reader, ref tmp) as HLAupdateAttributeValuesMessage; decodedValue.ObjectInstanceHandle = reader.ReadHLAinteger64BE(); decodedValue.AttributeHandleValuePairList = new HLAattributeHandleValuePair[reader.ReadHLAinteger32BE()]; for (int i = 0; i < decodedValue.AttributeHandleValuePairList.Length; i++) { tmp = BaseInteractionMessage.NullBaseInteractionMessage; decodedValue.AttributeHandleValuePairList[i] = (HLAattributeHandleValuePair)hlaAttributeHandleValuePairXrtiSerializer.Deserialize(reader, ref tmp); } } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
///<summary> Reads this HLAfederateMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLAfederateMessage decodedValue; if (!(msg is HLAfederateMessage)) { decodedValue = new HLAfederateMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAfederateMessage; } object tmp = decodedValue; decodedValue = base.Deserialize(reader, ref tmp) as HLAfederateMessage; try { /* * decodedValue.HLAfederate = new byte[reader.ReadHLAinteger32BE()]; * * for (int i = 0; i < decodedValue.HLAfederate.Length; i++) * { * decodedValue.HLAfederate[i] = reader.ReadHLAoctet(); * } */ decodedValue.HLAfederate = (HLAfederateHandle)reader.ReadHLAinteger32BE(); } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
///<summary> Reads this PeerAdvertisementInteractionMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { PeerAdvertisementInteractionMessage decodedValue; if (!(msg is PeerAdvertisementInteractionMessage)) { decodedValue = new PeerAdvertisementInteractionMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as PeerAdvertisementInteractionMessage; } //object tmp = decodedValue; //decodedValue = base.Deserialize(reader, ref tmp) as PeerAdvertisementInteractionMessage; try { decodedValue.PeerName = reader.ReadHLAunicodeString(); decodedValue.PeerDescription = reader.ReadHLAunicodeString(); decodedValue.PeerChannels = new ConnectionList(); int PeerChannelsLength = reader.ReadHLAinteger32BE(); for (int i = 0; i < PeerChannelsLength; i++) { decodedValue.PeerChannels.Add(reader.ReadHLAunicodeString()); } } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
public void OnReceiveHLAupdateAttributeValuesReliableBase(BaseInteractionMessage msg) { OnReceiveHLAupdateAttributeValuesReliable(msg as HLAupdateAttributeValuesReliableMessage); }
public abstract void ReceiveInteraction(BaseInteractionMessage msg);
/// <summary>Notifies the listener of a received interaction.</summary> /// <param name="msg"> the message of the received interaction</param> public void ReceiveInteraction(BaseInteractionMessage msg) { try { lock (manager.InteractionListeners) { if (msg is HLAcreateFederationExecutionMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IMetaFederationObjectModelInteractionListener) { (il as IMetaFederationObjectModelInteractionListener).OnReceiveHLAcreateFederationExecution(msg as HLAcreateFederationExecutionMessage); } else { il.ReceiveInteraction(msg); } } } else if (msg is HLAdestroyFederationExecutionMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IMetaFederationObjectModelInteractionListener) { (il as IMetaFederationObjectModelInteractionListener).OnReceiveHLAdestroyFederationExecution(msg as HLAdestroyFederationExecutionMessage); } else { il.ReceiveInteraction(msg); } } } else if (msg is HLAjoinFederationExecutionMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IMetaFederationObjectModelInteractionListener) { (il as IMetaFederationObjectModelInteractionListener).OnReceiveHLAjoinFederationExecution(msg as HLAjoinFederationExecutionMessage); } else { il.ReceiveInteraction(msg); } } } else { foreach (IInteractionListener il in manager.InteractionListeners) { il.ReceiveInteraction(msg); } } } } catch (System.IO.IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
public virtual void SendRealiableInteraction(StreamMessageChannel messageChannel, BaseInteractionMessage msg) { try { lock (messageChannel.SyncObject) { /* * if (log.IsDebugEnabled) * log.Debug("Sending Interaction: " + msg); */ serializer.Serialize(messageChannel.OutputStream, msg); } } catch (System.Exception e) { throw new RTIinternalError(e.Message); } }
/// <summary>Notifies the listener of a received interaction.</summary> /// <param name="msg"> the message of the received interaction</param> public void ReceiveInteraction(BaseInteractionMessage msg) { #if POSIBLE_MEJORA if (bootstrapInteractionsDelegates[msg.FederationExecutionHandle].ContainsKey(msg.GetType())) { bootstrapInteractionsDelegates[msg.FederationExecutionHandle][msg.GetType()](msg); } else { bootstrapInteractionsDelegates[msg.FederationExecutionHandle][typeof(BaseInteractionMessage)](msg); } #endif try { if (msg is HLAGenericInteractionMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IBootstrapObjectModelInteractionListener) { (il as IBootstrapObjectModelInteractionListener).OnReceiveHLAGenericInteraction(msg as HLAGenericInteractionMessage); } else { il.ReceiveInteraction(msg); } } } else if (msg is HLAinteractionFragmentMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IBootstrapObjectModelInteractionListener) { (il as IBootstrapObjectModelInteractionListener).OnReceiveHLAinteractionFragment(msg as HLAinteractionFragmentMessage); } else { il.ReceiveInteraction(msg); } } } else if (msg is HLAcontinueMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IBootstrapObjectModelInteractionListener) { (il as IBootstrapObjectModelInteractionListener).OnReceiveHLAcontinue(msg as HLAcontinueMessage); } else { il.ReceiveInteraction(msg); } } } else if (msg is PeerAdvertisementInteractionMessage) { foreach (IInteractionListener il in manager.InteractionListeners) { if (il is IBootstrapObjectModelInteractionListener) { (il as IBootstrapObjectModelInteractionListener).OnReceivePeerAdvertisementInteraction(msg as PeerAdvertisementInteractionMessage); } else { il.ReceiveInteraction(msg); } } } else { foreach (IInteractionListener il in manager.InteractionListeners) { il.ReceiveInteraction(msg); } } } catch (System.IO.IOException ioe) { throw new FederateInternalError(ioe.ToString()); } }
public override void ReceiveInteraction(BaseInteractionMessage msg) { if (log.IsDebugEnabled) log.Debug("Received BaseInteraction Message = " + msg.ToString()); }