<p dir="ltr">Junxiao,</p>
<p dir="ltr">You mean encode a packet into a type (e.g. Link) then decode it, to be able to do some process with it? </p>
<p dir="ltr">What if peeking into link service? Or it will be more difficult from programming perspective?</p>
<p dir="ltr">Thanks,<br>
Sabet</p>
<p dir="ltr">On 9 Oct 2016 8:21 pm, "Junxiao Shi" <<a href="mailto:shijunxiao@email.arizona.edu">shijunxiao@email.arizona.edu</a>> wrote:<br>
><br>
> Hi Sabet<br>
><br>
> When a Data instance is created during packet decoding, the instance is of Data type, not a subclass of Data. Thus, you cannot downcast it with static_cast.<br>
><br>
> If it's determined that the Data is a Link, you may construct a new Link instance and decode from the wire encoding:<br>
>><br>
>> ndn::Link link(data.wireEncode());<br>
><br>
><br>
> Similarly, you can:<br>
>><br>
>> ndn::security::v1::Certificate cert(data);<br>
><br>
> Certificate has a constructor from Data, which allows you to omit wireEncode().<br>
><br>
> ContentType=NACK refers to producer generated Nack, which has no particular structure. A producer generated Nack is just a regular Data.<br>
> This is completely unrelated to ndn::lp::Nack.<br>
><br>
> Yours, Junxiao<br>
><br>
><br>
> On Sun, Oct 9, 2016 at 7:36 AM, Muhammad Hosain Abdollahi Sabet <<a href="mailto:mhasabet@gmail.com">mhasabet@gmail.com</a>> wrote:<br>
>><br>
>> ​Hello everyone,<br>
>>  <br>
>> My application recieves a Data packet. How can I downcast it to its Type? I mean, for example downcast a data packet to Key or Link or Nack based on getContentType of the packet. I know it is more of a c++ question, but again I haven't been able to do it yet in ndnSIM.<br>
>>  <br>
>> Thanks,<br>
>> Sabet<br>
><br>
></p>