Roboid Control for C#
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
RoboidControl.ParticipantUDP Class Reference

Detailed Description

A participant using UDP communication.

A local participant is the local device which can communicate with other participants It manages all local things and communcation with other participants. Each application has a local participant which is usually explicit in the code. An participant can be isolated. In that case it is standalong and does not communicate with other participants.

It is possible to work with an hidden participant by creating things without specifying a participant in the constructor. In that case an hidden isolated participant is created which can be obtained using RoboidControl::IsolatedParticipant::Isolated().

See also
RoboidControl::Thing::Thing()
Inheritance diagram for RoboidControl.ParticipantUDP:
RoboidControl.Participant RoboidControl.SiteServer

Public Member Functions

 ParticipantUDP (int port=0)
 Create a participant without connecting to a site.
 
 ParticipantUDP (string ipAddress, int port=7681, int localPort=7681)
 Create a participant which will try to connect to a site.
 
override void Update (ulong currentTimeMS=0)
 Update all things for this participant.
 
void SendThingInfo (Participant owner, Thing thing)
 
void PublishThingInfo (Thing thing)
 
bool Send (Participant owner, IMessage msg)
 
bool Publish (IMessage msg)
 
void ReceiveData (byte[] data, Participant sender)
 
Thing Get (byte thingId)
 Get the thing with the given properties.
 
void Add (Thing thing, bool checkId=true)
 Add a new thing for this participant.
 
void Remove (Thing thing)
 Remove a thing for this participant.
 

Static Public Member Functions

static ParticipantUDP Isolated ()
 Isolated participant is used when the application is run without networking.
 
static Participant GetParticipant (string ipAddress, int port)
 Retrieve a participant using ip address and port number.
 
static Participant GetParticipant (int networkId)
 Retrieve a participant using a network ID.
 
static Participant AddParticipant (string ipAddress, int port)
 Add a new participant to the collection of participants.
 
static void AddParticipant (Participant participant)
 Add a new participant to the collection of participants.
 

Public Attributes

string name = "ParticipantUDP"
 The name of the participant.
 
bool isIsolated = false
 True if the participant is running isolated.
 
Participant remoteSite = null
 The remote site when this participant is connected to a site.
 
ulong publishInterval = 3000
 The interval in milliseconds for publishing (broadcasting) data on the local network.
 
byte[] buffer = new byte[1024]
 
IPEndPoint endPoint = null
 
UdpClient udpClient = null
 
string broadcastIpAddress = "255.255.255.255"
 
readonly ConcurrentQueue< IMessagemessageQueue = new ConcurrentQueue<IMessage>()
 
string ipAddress = "0.0.0.0"
 The Ip Address of a participant. When the participant is local, this contains 0.0.0.0.
 
int port = 0
 The port number for UDP communication with the participant. This is 0 for isolated participants.
 
byte networkId = 0
 he network Id to identify the participant
 
readonly List< Thingthings = new()
 The things managed by this participant.
 

Static Public Attributes

static readonly List< Participantparticipants = new()
 The collection of known participants.
 

Protected Member Functions

void GetBroadcastAddress (IPAddress ip, IPAddress subnetMask)
 
virtual void UpdateMyThings (ulong currentTimeMS)
 
virtual void UpdateOtherThings (ulong currentTimeMS)
 
void ReceiveUDP (IAsyncResult result)
 
virtual void Process (Participant sender, ParticipantMsg msg)
 
virtual void Process (Participant sender, NetworkIdMsg msg)
 
virtual void Process (Participant sender, InvestigateMsg msg)
 
virtual void Process (Participant sender, ThingMsg msg)
 
virtual void Process (Participant sender, NameMsg msg)
 
virtual void Process (Participant sender, ModelUrlMsg msg)
 
virtual void Process (Participant sender, PoseMsg msg)
 
virtual void Process (Participant sender, BinaryMsg msg)
 
virtual void Process (Participant sender, TextMsg msg)
 
virtual void Process (Participant sender, DestroyMsg msg)
 

Protected Attributes

ulong nextPublishMe = 0
 

Constructor & Destructor Documentation

◆ ParticipantUDP() [1/2]

RoboidControl.ParticipantUDP.ParticipantUDP ( int  port = 0)

Create a participant without connecting to a site.

Parameters
portThe port number on which to communicate

These participant typically broadcast Participant messages to let site servers on the local network know their presence. Alternatively they can broadcast information which can be used directly by other participants.

◆ ParticipantUDP() [2/2]

RoboidControl.ParticipantUDP.ParticipantUDP ( string  ipAddress,
int  port = 7681,
int  localPort = 7681 
)

Create a participant which will try to connect to a site.

Parameters
ipAddressThe ip address of the site server
portThe port number of the site server
localPortThe port used by the local participant

Member Function Documentation

◆ Isolated()

static ParticipantUDP RoboidControl.ParticipantUDP.Isolated ( )
static

Isolated participant is used when the application is run without networking.

Returns
A participant without networking support

◆ Update()

override void RoboidControl.ParticipantUDP.Update ( ulong  currentTimeMS = 0)
virtual

Update all things for this participant.

Parameters
currentTimeMSThe current time in milliseconds (optional)

Reimplemented from RoboidControl.Participant.

◆ Get()

Thing RoboidControl.Participant.Get ( byte  thingId)
inherited

Get the thing with the given properties.

Parameters
thingIdThe ID of the thing
Returns
The thing when it is found, null in other cases.

◆ Add()

void RoboidControl.Participant.Add ( Thing  thing,
bool  checkId = true 
)
inherited

Add a new thing for this participant.

Parameters
thingThe thing to add
checkIdIf true, the thing.id is regenerated if it is zero

◆ Remove()

void RoboidControl.Participant.Remove ( Thing  thing)
inherited

Remove a thing for this participant.

Parameters
thingThe thing to remove

◆ GetParticipant() [1/2]

static Participant RoboidControl.Participant.GetParticipant ( string  ipAddress,
int  port 
)
staticinherited

Retrieve a participant using ip address and port number.

Parameters
ipAddressThe ip address of the participant
portThe port number used to send messages to the participant
Returns
The participant or null if it is not found.

◆ GetParticipant() [2/2]

static Participant RoboidControl.Participant.GetParticipant ( int  networkId)
staticinherited

Retrieve a participant using a network ID.

Parameters
networkIdThe network ID of the participant
Returns
The participant or null if it is not found.

◆ AddParticipant() [1/2]

static Participant RoboidControl.Participant.AddParticipant ( string  ipAddress,
int  port 
)
staticinherited

Add a new participant to the collection of participants.

Parameters
ipAddressThe IP address of the participant
portThe port used to send messages to this participant
Returns
The added participant

◆ AddParticipant() [2/2]

static void RoboidControl.Participant.AddParticipant ( Participant  participant)
staticinherited

Add a new participant to the collection of participants.

Parameters
participantThe participant to add

<note>This function only adds the participant if it is not yet in the collection</note>

Member Data Documentation

◆ isIsolated

bool RoboidControl.ParticipantUDP.isIsolated = false

True if the participant is running isolated.

Isolated participants do not communicate with other participants