-
Notifications
You must be signed in to change notification settings - Fork 5
PDUSender
The PDU Sender is required for setting up UDP send sockets.
public class PDUSender
: MonoBehaviour
- OpenDis.Core
- OpenDis.Dis1998
- System
- System.Collections.Concurrent
- System.Net
- System.Net.Sockets
- System.Threading
- UnityEngine
- UnityEngine.Events
Access | Type | Name | Description | |
---|---|---|---|---|
Public | bool | autoConnectAtStart | Whether or not to auto connect the receive address on start. | |
Public | EConnectionType | ConnectionType | The type of connection used in sending out the PDUs. | |
Private | DataOutputStream | dos | The data stream that is used to convert PDUs to bytes prior to emitting them as UDP packets. | |
Private | Exception | exception | The exception that is used if the PDU Sender fails at some point during its runtime. Contains reasoning behind the failure. | |
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 | int | maxQueueSize | The maximum number of queued PDUs before the most recent ones get removed. | |
Private | ConcurrentQueue<byte[]> | pdus | The concurrent queue that houses all PDUs that are awaiting being sent on the network. | |
Public | int | port | The Port to receive UDP packets from. Valid Port ranges are from 1024 to 65535. | |
Private | bool | sending | Whether or not the PDU Sender is currently sending PDUs. | |
Private | Thread | thread | The thread that is responsible for running the PDU Sender. |
Event Type | Event Name | Description |
---|---|---|
UnityEvent<Exception> | OnFailedToConnect | Called if the UDP sender fails to connect to the given IP Address/Port. |
Access | Return | Name | Description | |
---|---|---|---|---|
Private | void | Awake() | Awake is called when the script instance is being loaded. | |
Public | void | ChangeAddress(string IP, int port) | Changes the IP of the UDP Sender safely | |
Public | void | Init() | Starts up the thread from the desired ip. | |
Public | bool | IsConnected() | Gets whether or not the PDU Sender is currently connected. | |
Private | Static | IPAddress | LocalIPAddress() | Gets the local ip address of the machine the UDP sender is being run on. |
Private | void | OnApplicationQuit() | Sent to all GameObjects before the application quits. Unity calls this message when play mode is stopped. | |
Private | void | SenderWork(IPAddress targetIP) | Method run by the thread. | |
Public | void | SendPdu(AcknowledgePdu pdu) | Method to send AcknowledgePDUs. | |
Public | void | SendPdu(ActionRequestPdu pdu) | Method to send ActionRequestPDUs. | |
Public | void | SendPdu(ActionResponsePdu pdu) | Method to send ActionResponsePDUs. | |
Public | void | SendPdu(CollisionPdu pdu) | Method to send CollisionPDUs. | |
Public | void | SendPdu(CommentPdu pdu) | Method to send CommentPDUs. | |
Public | void | SendPdu(CreateEntityPdu pdu) | Method to send CreateEntityPDUs. | |
Public | void | SendPdu(DataPdu pdu) | Method to send DataPDUs. | |
Public | void | SendPdu(DataQueryPdu pdu) | Method to send DataQueryPDUs. | |
Public | void | SendPdu(DesignatorPdu pdu) | Method to send DesignatorPDUs. | |
Public | void | SendPdu(DetonationPdu pdu) | Method to send DetonationPDUs. | |
Public | void | SendPdu(ElectronicEmissionsPdu pdu) | Method to send ElectronicEmissionsPDUs. | |
Public | void | SendPdu(EntityStatePdu pdu) | Method to send EntityStatePDUs. | |
Public | void | SendPdu(EntityStateUpdatePdu pdu) | Method to send EntityStateUpdatePDUs. | |
Public | void | SendPdu(EventReportPdu pdu) | Method to send EventReportPDUs. | |
Public | void | SendPdu(FirePdu pdu) | Method to send FirePDUs. | |
Public | void | SendPdu(ReceiverPdu pdu) | Method to send ReceiverPDUs. | |
Public | void | SendPdu(RemoveEntityPdu pdu) | Method to send RemoveEntityPDUs. | |
Public | void | SendPdu(RepairCompletePdu pdu) | Method to send RepairCompletePDUs. | |
Public | void | SendPdu(RepairResponsePdu pdu) | Method to send RepairResponsePDUs. | |
Public | void | SendPdu(ResupplyCancelPdu pdu) | Method to send ResupplyCancelPDUs. | |
Public | void | SendPdu(ResupplyOfferPdu pdu) | Method to send ResupplyOfferPDUs. | |
Public | void | SendPdu(ResupplyReceivedPdu pdu) | Method to send ResupplyReceivedPDUs. | |
Public | void | SendPdu(ServiceRequestPdu pdu) | Method to send ServiceRequestPDUs. | |
Public | void | SendPdu(SetDataPdu pdu) | Method to send SetDataPDUs. | |
Public | void | SendPdu(SignalPdu pdu) | Method to send SignalPDUs. | |
Public | void | SendPdu(StartResumePdu pdu) | Method to send StartResumePDUs. | |
Public | void | SendPdu(StopFreezePdu pdu) | Method to send StopFreezePDUs. | |
Public | void | SendPdu(TransmitterPdu pdu) | Method to send TransmitterPDUs. | |
Public | void | Stop() | Stops the thread and disconnects. |
public bool autoConnectAtStart = true
Whether or not to auto connect the receive address on start.
public EConnectionType connectionType
The type of connection used in sending out the PDUs.
private DataOutputStream dos = new DataOutputStream(Endian.Big)
The data stream that is used to convert PDUs to bytes prior to emitting them as UDP packets.
private Exception exception
The exception that is used if the PDU Sender fails at some point during its runtime. Contains reasoning behind the failure.
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.
public int maxQueueSize = 1 * 1024
The maximum number of queued PDUs before the most recent ones get removed.
private ConcurrentQueue<byte[]> pdus
The concurrent queue that houses all PDUs that are awaiting being sent on the network.
public int port = 3000
The Port to receive UDP packets from. Valid Port ranges are from 1024 to 65535.
private bool sending = true
Whether or not the PDU Sender is currently sending PDUs.
private Thread thread
The thread that is responsible for running the PDU Sender.
public UnityEvent<Exception> OnFailedToConnect
Called if the UDP sender fails to connect to the given IP Address/Port.
Parameter | Description |
---|---|
Exception | The exception that contains the reasoning behind why the UDP sender failed to connect. |
private void Awake()
Awake is called when the script instance is being loaded.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html
public void ChangeAddress
(
string IP,
int port
)
Changes the IP of the UDP Sender safely
Parameter | Description |
---|---|
IP | The new IP to change the UDP sender to. |
port | The new port to change the UDP sender to. |
public void Init()
Starts up the thread from the desired ip.
public bool IsConnected()
Gets whether or not the PDU Sender is currently connected.
Returns |
---|
Whether or not the PDU Sender is currently connected. |
private static IPAddress LocalIPAddress()
Gets the local ip address of the machine the UDP sender is being run on.
Returns |
---|
The local ip address of the machine the UDP sender is being run on. |
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
private void SenderWork
(
IPAddress targetIP
)
Method run by the thread.
Parameter | Description |
---|---|
targetIP | The target IP to connect the UDP sender to if Unicast or Multicast is being used. |
public void SendPdu
(
AcknowledgePdu pdu
)
Method to send AcknowledgePDUs.
Parameter | Description |
---|---|
pdu | The AcknowledgePDU to send out. |
public void SendPdu
(
ActionRequestPdu pdu
)
Method to send ActionRequestPDUs.
Parameter | Description |
---|---|
pdu | The ActionRequestPDU to send out. |
public void SendPdu
(
ActionResponsePdu pdu
)
Method to send ActionResponsePDUs.
Parameter | Description |
---|---|
pdu | The ActionResponsePDU to send out. |
public void SendPdu
(
CollisionPdu pdu
)
Method to send CollisionPDUs.
Parameter | Description |
---|---|
pdu | The CollisionPDU to send out. |
public void SendPdu
(
CommentPdu pdu
)
Method to send CommentPDUs.
Parameter | Description |
---|---|
pdu | The CommentPDU to send out. |
public void SendPdu
(
CreateEntityPdu pdu
)
Method to send CreateEntityPDUs.
Parameter | Description |
---|---|
pdu | The CreateEntityPDU to send out. |
public void SendPdu
(
DataPdu pdu
)
Method to send DataPDUs.
Parameter | Description |
---|---|
pdu | The DataPDU to send out. |
public void SendPdu
(
DataQueryPdu pdu
)
Method to send DataQueryPDUs.
Parameter | Description |
---|---|
pdu | The DataQueryPDU to send out. |
public void SendPdu
(
DesignatorPdu pdu
)
Method to send DesignatorPDUs.
Parameter | Description |
---|---|
pdu | The DesignatorPDU to send out. |
public void SendPdu
(
DetonationPdu pdu
)
Method to send DetonationPDUs.
Parameter | Description |
---|---|
pdu | The DetonationPDU to send out. |
public void SendPdu
(
ElectronicEmissionsPdu pdu
)
Method to send ElectronicEmissionsPDUs.
Parameter | Description |
---|---|
pdu | The ElectronicEmissionsPDU to send out. |
public void SendPdu
(
EntityStatePdu pdu
)
Method to send EntityStatePDUs.
Parameter | Description |
---|---|
pdu | The EntityStatePDU to send out. |
public void SendPdu
(
EntityStateUpdatePdu pdu
)
Method to send EntityStateUpdatePDUs.
Parameter | Description |
---|---|
pdu | The EntityStateUpdatePDU to send out. |
public void SendPdu
(
EventReportPdu pdu
)
Method to send EventReportPDUs.
Parameter | Description |
---|---|
pdu | The EventReportPDU to send out. |
public void SendPdu
(
FirePdu pdu
)
Method to send FirePDUs.
Parameter | Description |
---|---|
pdu | The FirePDU to send out. |
public void SendPdu
(
ReceiverPdu pdu
)
Method to send ReceiverPDUs.
Parameter | Description |
---|---|
pdu | The ReceiverPDU to send out. |
public void SendPdu
(
RemoveEntityPdu pdu
)
Method to send RemoveEntityPDUs.
Parameter | Description |
---|---|
pdu | The RemoveEntityPDU to send out. |
public void SendPdu
(
RepairCompletePdu pdu
)
Method to send RepairCompletePDUs.
Parameter | Description |
---|---|
pdu | The RepairCompletePDU to send out. |
public void SendPdu
(
RepairResponsePdu pdu
)
Method to send RepairResponsePDUs.
Parameter | Description |
---|---|
pdu | The RepairResponsePDU to send out. |
public void SendPdu
(
ResupplyCancelPdu pdu
)
Method to send ResupplyCancelPDUs.
Parameter | Description |
---|---|
pdu | The ResupplyCancelPDU to send out. |
public void SendPdu
(
ResupplyOfferPdu pdu
)
Method to send ResupplyOfferPDUs.
Parameter | Description |
---|---|
pdu | The ResupplyOfferPDU to send out. |
public void SendPdu
(
ResupplyReceivedPdu pdu
)
Method to send ResupplyReceivedPDUs.
Parameter | Description |
---|---|
pdu | The ResupplyReceivedPDU to send out. |
public void SendPdu
(
ServiceRequestPdu pdu
)
Method to send ServiceRequestPDUs.
Parameter | Description |
---|---|
pdu | The ServiceRequestPDU to send out. |
public void SendPdu
(
SetDataPdu pdu
)
Method to send SetDataPDUs.
Parameter | Description |
---|---|
pdu | The SetDataPDU to send out. |
public void SendPdu
(
SignalPdu pdu
)
Method to send SignalPDUs.
Parameter | Description |
---|---|
pdu | The SignalPDU to send out. |
public void SendPdu
(
StartResumePdu pdu
)
Method to send StartResumePDUs.
Parameter | Description |
---|---|
pdu | The StartResumePDU to send out. |
public void SendPdu
(
StopFreezePdu pdu
)
Method to send StopFreezePDUs.
Parameter | Description |
---|---|
pdu | The StopFreezePDU to send out. |
public void SendPdu
(
TransmitterPdu pdu
)
Method to send TransmitterPDUs.
Parameter | Description |
---|---|
pdu | The TransmitterPDU to send out. |
public void Stop()
Stops the thread and disconnects.