Packet structure

The most “complicated” thing with this library is clearly the packet structure. We have to keep some things in mind to guarantee a flawless serialization. We differ between two packet types. The Request and the response packet.

Request Packet

The request packet is used to “start” a conversation. We literally request something.

  1. We always need a default empty constructor. The network library is going to create instances of classes on demand. Because the parameters are not known, an empty constructor is needed.
    With version 5.2.2.6 a default constructor isn’t required anymore.
  2. You can manipulate data before receiving and sending with the method “BeforeReceive” and “BeforeSend”. Data types, which are not supported by the library, could be converted in those methods.
  3. Use the [PacketIgnorePropertyAttribute] on properties if you don’t want to send them over the network.

Response Packet

The response packet is an answer to a request. Therefore, it has to contain the question as well.

  1. The “CalculationResponse” class owns an attribute called “PacketRequest”. The network library is able to map the response to the request, and the other way around. This attribute is required
  2. We always need a default empty constructor.
    With version 5.2.2.6 a default constructor isn’t required anymore.
  3. We always need a constructor with at least the RequestPacket as a parameter. ( : base(request))
  4. You can manipulate data before receiving and sending with the method “BeforeReceive” and “BeforeSend”. Data types, which are not supported by the library, could be converted in those methods.
  5. Use the [PacketIgnorePropertyAttribute] on properties if you don’t want to send them over the network.

Schreibe einen Kommentar

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.