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 objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.

Methods

    public int GetAvailablePacketCount()

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

    public byte[] GetPacket()

Gets a raw packet.

    public Error GetPacketError()

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

    public object GetVar(bool allowObjects = false)

Gets a Variant. If allowObjects (or AllowObjectDecoding) is true, decoding objects is allowed.

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

    [Obsolete("IsObjectDecodingAllowed is deprecated. Use the AllowObjectDecoding property instead.")]
    public bool IsObjectDecodingAllowed()

Getter for AllowObjectDecoding

    public Error PutPacket(byte[] buffer)

Sends a raw packet.

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

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

    [Obsolete("SetAllowObjectDecoding is deprecated. Use the AllowObjectDecoding property instead.")]
    public void SetAllowObjectDecoding(bool enable)

Setter for AllowObjectDecoding

Tags: