Skip to content

PDUReceiver

huggins edited this page May 10, 2023 · 1 revision

PDU Receiver

The PDU Receiver is required for setting up UDP receive sockets.

public class PDUReceiver 
  : MonoBehaviour

Includes

Back to Top


Members

Access Type Name Description
Public bool allowLoopback Whether or not packets sent by the local machine should be processed.
Public bool autoConnectAtStart Whether or not to auto connect the receive address on start.
Private DISGameManager disManagerScript A reference to the DISGameManager script
Private IPAddress ipAddress The .Net container for the IP Address to use for receiving UDP messages.
Public string ipAddressString The IP Address to receive UDP packets from. An IP Address of 0.0.0.0 listens to all connection on the specified port.
Public string multicastAddress The multicast address to receive UDP packets from. DIS transient multicast groups range from 224.252.0.0 - 224.255.255.255 per IANA standards.
Private PDUProcessor pduProcessor A reference to the PDUProcessor script.
Public int port The Port to receive UDP packets from. Valid Port ranges are from 1024 to 65535.
Private UDPReceiverMulti receiver The UDP Receiver Multi class that this PDU Receiver is registered to.
Public bool useMulticast Whether or not multicast should be used with this receive socket.

Back to Top


Events

Event Type Event Name Description
UnityEvent<Exception> OnFailedToConnect Called if the UDP receiver fails to connect to the given IP Address/Port.

Functions

Access Return Name Description
Public void FailedToConnect(Exception ex) Called when the UDP receiver fails to connect to the given IP Address/port.
Private void OnApplicationQuit() Sent to all GameObjects before the application quits. Unity calls this message when play mode is stopped.
Private void ProcessDISPacket(Pdu PDUPacketToProcess) Process newly received DIS PDU packets.
Private void Start() Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.
Public void startUDPReceiver() Initializes the UDP Receiver with the specified variables and begins listening for UDP messages.
Public void stopUDPReceiver() Stops the UDP receiver.
Private void Update() Update is called every frame, if the MonoBehaviour is enabled.

Back to Top


Details

AllowLoopback

public bool allowLoopback = false

Whether or not packets sent by the local machine should be processed.

Back to Top


AutoConnectAtStart

public bool autoConnectAtStart = true

Whether or not to auto connect the receive address on start.

Back to Top


DISManagerScript

private DISGameManager disManagerScript

A reference to the DISGameManager script

Back to Top


IPAddress

private IPAddress ipAddress

The .Net container for the IP Address to use for receiving UDP messages.

Back to Top


IPAddressString

public string ipAddressString = "0.0.0.0"

The IP Address to receive UDP packets from. An IP Address of 0.0.0.0 listens to all connection on the specified port.

Back to Top


MulticastAddress

public string multicastAddress = "224.252.0.1"

The multicast address to receive UDP packets from. DIS transient multicast groups range from 224.252.0.0 - 224.255.255.255 per IANA standards.

Back to Top


PDUProcessor

private PDUProcessor pduProcessor

A reference to the PDUProcessor script.

Back to Top


Port

public int port = 3000

The Port to receive UDP packets from. Valid Port ranges are from 1024 to 65535.

Back to Top


Receiver

private UDPReceiverMulti.UDPReceiverMulti receiver

The UDP Receiver Multi class that this PDU Receiver is registered to.

Back to Top


UseMulticast

public bool useMulticast = false

Whether or not multicast should be used with this receive socket.

Back to Top


OnFailedToConnect

public UnityEvent<Exception> OnFailedToConnect

Called if the UDP receiver fails to connect to the given IP Address/Port.

Parameter Description
Exception The exception that contains the reasoning behind why the UDP receiver failed to connect.

Back to Top


FailedToConnect

public void FailedToConnect
(
    Exception ex
)

Called when the UDP receiver fails to connect to the given IP Address/port.

Parameter Description
Exception The exception that contains the reasoning behind why the UDP receiver failed to connect.

Back to Top


OnApplicationQuit

private void OnApplicationQuit()

Sent to all GameObjects before the application quits. Unity calls this message when play mode is stopped.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html

Back to Top


ProcessDISPacket

private void ProcessDISPacket
(
    Pdu PDUPacketToProcess
)

Process newly received DIS PDU packets.

Parameter Description
PDUPacketToProcess The PDU packet to process to determine the type of.

Back to Top


Start

private void Start()

Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html

Back to Top


StartUDPReceiver

public void startUDPReceiver()

Initializes the UDP Receiver with the specified variables and begins listening for UDP messages.

Back to Top


StopUDPReceiver

public void stopUDPReceiver()

Stops the UDP receiver.

Back to Top


Update

void Update()

Update is called every frame, if the MonoBehaviour is enabled.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html

Back to Top