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

Detailed Description

A participant is a device which manages things.

It can communicate with other participant to synchronise the state of things. This class is used to register the things the participant is managing. It also maintains the communcation information to contact the participant. It is used as a basis for the local participant, but also as a reference to remote participants.

Inheritance diagram for RoboidControl.Participant:
RoboidControl.ParticipantUDP RoboidControl.SiteServer

Classes

class  UpdateEvent
 Event for a participant. More...
 

Public Member Functions

 Participant ()
 Create a generic participant.
 
 Participant (string ipAddress, int port, Participant localParticipant=null)
 Create a new participant with the given communcation info.
 
Thing Get (byte networkId, 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.
 
virtual void Update ()
 Update all things for this participant.
 
virtual bool Send (IMessage msg)
 
void SendThingInfo (Thing thing)
 

Static Public Member Functions

static void ReplaceLocalParticipant (Participant newParticipant)
 Replace the local participant.
 
static Participant GetParticipant (int networkId)
 Retrieve a participant using ip address and port number.
 
static void AddParticipant (Participant participant)
 Add a new participant to the collection of participants.
 

Public Attributes

byte networkId = 0
 The network Id to identify the participant.
 
bool isRemote = false
 
Thing root = null
 The root thing for this participant.
 
readonly List< Thingthings = new()
 The things managed by this participant.
 
Unity.Participant component = null
 A reference to the representation of the thing in Unity.
 
ConcurrentQueue< UpdateEventupdateQueue = new()
 Queue containing events happened to this participant.
 
byte[] buffer = new byte[1024]
 

Static Public Attributes

static Participant localParticipant = new()
 The local participant for this application.
 
static readonly List< Participantparticipants = new()
 The collection of known participants.
 

Constructor & Destructor Documentation

◆ Participant()

RoboidControl.Participant.Participant ( string  ipAddress,
int  port,
Participant  localParticipant = null 
)

Create a new participant with the given communcation info.

Parameters
ipAddressThe IP address of the participant
portThe UDP port of the participant

This does not belong here, it should move to ParticipantUDP or something like that in the future

Member Function Documentation

◆ ReplaceLocalParticipant()

static void RoboidControl.Participant.ReplaceLocalParticipant ( Participant  newParticipant)
static

Replace the local participant.

Parameters
newParticipantThe new local participant

◆ Get()

Thing RoboidControl.Participant.Get ( byte  networkId,
byte  thingId 
)

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 
)

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)

Remove a thing for this participant.

Parameters
thingThe thing to remove

◆ Update()

virtual void RoboidControl.Participant.Update ( )
virtual

Update all things for this participant.

Reimplemented in RoboidControl.ParticipantUDP, and RoboidControl.SiteServer.

◆ GetParticipant()

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

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.

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()

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

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>