Abstraction and base class for packet-based protocols.
    public abstract class PacketPeer : Reference

PacketPeer is an abstraction and base class for packet-based protocols (such as UDP). It provides an API for sending and receiving packets both as raw data or variables. This makes it easy to transfer data over a protocol, without having to encode data as low level bytes or having to worry about network ordering.

Inheritance Chain

Derived Classes

Properties

    public bool AllowObjectDecoding { get; set; }

Deprecated. Use get_var and put_var parameters instead.

If true the PacketPeer will allow encoding and decoding of object via GetVar(bool) and PutVar(object, bool).

WARNING: Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).

Methods

    public int GetAvailablePacketCount()

Return the number of packets currently available in the ring-buffer.

    public byte[] GetPacket()

Get a raw packet.

    public Error GetPacketError()

Return the error state of the last packet received (via GetPacket() and GetVar(bool)).

    public object GetVar(bool allowObjects = false)

Get a Variant. When allowObjects (or AllowObjectDecoding) is true decoding objects is allowed.

WARNING: Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).

    public bool IsObjectDecodingAllowed()

Getter for AllowObjectDecoding

    public Error PutPacket(byte[] buffer)

Send a raw packet.

    public Error PutVar(object var, bool fullObjects = false)

Send a Variant as a packet. When fullObjects (or AllowObjectDecoding) is true encoding objects is allowed (and can potentially include code).

    public void SetAllowObjectDecoding(bool enable)

Setter for AllowObjectDecoding

Tags: