Ejemplo n.º 1
0
 /// <summary>
 /// Gets called when new data packet is received.
 /// </summary>
 /// <param name="data">Received data</param>
 public virtual void LinkLayerCallback(LinkLayerHeader lLinkLayerHeader)
 {
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets called when new data packet is received.
        /// </summary>
        /// <param name="data">Received data</param>
        public override void LinkLayerCallback(LinkLayerHeader lLinkLayerHeader)
        {
            int offset = 0;

            //Deserialize ProtocolLayer header.
            BPProtocolHeader lProtocolHeader = (BPProtocolHeader)cHeaderSerializer.DeserializeData(lLinkLayerHeader.GetData(), 0, ref offset)[0];

            //Try to find operation by using id in ProtocolHeader
            BPOperation lOperation;
            try
            {
                lOperation = (from o in cOperations where o.cRecvCode == lProtocolHeader.cOperationId select o).First();
            }
            catch
            { return; }

            //If we have DownlinkSerializer, then we deserialize data inside.
            object[] DeserializedData = null;
            if (lOperation.cDownlinkSerializer != null)
            {
                DeserializedData = lOperation.cDownlinkSerializer.DeserializeData(lLinkLayerHeader.GetData(), offset, ref offset);
                if (DeserializedData == null) return;
            }

            //End of deserialization

            //If we have callback routine call it.
            if (lOperation.cCallbackDelegate != null)
                lOperation.cCallbackDelegate(lOperation.cOperationName, lProtocolHeader, lLinkLayerHeader.GetLinkId(), DeserializedData);
        }