Beispiel #1
0
        /// <summary>
        /// Generates an MIH Message based on a Link_Event_Subscribe_Confirm object.
        /// </summary>
        /// <param name="srcID">The source MIH ID.</param>
        /// <param name="dstID">The destination MIH ID</param>
        /// <param name="tid">The transaction ID, use the same as the request message.</param>
        /// <param name="leconfirm">The Link_Event_Subscribe_Confirm object to be the content of the message.</param>
        /// <returns>The MIH message to be sent to the MIHF.</returns>
        public static Message Event_Subscribe_Response_Builder(ID srcID, ID dstID, ushort tid, Link_Event_Subscribe_Confirm leconfirm)
        {
            Message m = new Message();
            m.MIHHeader = new MIHHeader();
            MessageID mID = new MessageID(MessageID.ServiceIdentifier.SERVICE_MANAGEMENT, MessageID.OperationCode.CONFIRM, (ushort)AIDServiceManagement.MIH_EVENT_SUBSCRIBE);
            m.MIHHeader.MID = mID;
            m.MIHHeader.TransactionID = tid;
            m.MIHHeader.VersionValue = 1;

            byte[] status = new byte[1];
            status[0]= BitConverter.GetBytes((int)leconfirm.Status)[0];

            m.Payload = new Payload(srcID, dstID,
                Serialization.SerializeToTLV(TLV_VALUES.TLV_STATUS, status),
                Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_EVENT_LIST, leconfirm.LinkEventList.ByteValue));
            m.MIHHeader.PayloadLength = (ushort)m.Payload.PayloadValue.Length;
            return m;
        }
Beispiel #2
0
 /// <summary>
 /// This method is called to handle a subscription request message
 /// </summary>
 /// <param name="m">The serialized subscription request message</param>
 public static void HandleSubscribe(Message m)
 {
     ConnectionHelper ch = Program.toMihf;
     ushort transactionID = m.MIHHeader.TransactionID;
     Payload.TLVIterator it = m.Payload.GetTLVIterator();
     ID srcID = new ID(new OctetString(it.Next().Value));
     ID dstID = new ID(new OctetString(it.Next().Value));
     Link_Event_Subscribe_Request lesr = new Link_Event_Subscribe_Request(MIHDeserializer.DeserializeLinkEventList(it.Next()));
     Subscriptions.Subscribe(lesr.EventList);
     Link_Event_Subscribe_Confirm lesc = new Link_Event_Subscribe_Confirm(STATUS.SUCCESS, lesr.EventList);
     ch.Send(ResponseBuilders.Event_Subscribe_Response_Builder(dstID, srcID, m.MIHHeader.TransactionID, lesc).ByteValue);
 }