Roboid Control for C# 0.4
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.SiteServer Class Reference

Detailed Description

A site server is a participant which provides a shared simulated environment.

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

Public Member Functions

 SiteServer (int port=7681)
 Create a new site server.
 
void Close ()
 Close the site.
 
override void Update ()
 Update all things for this participant.
 
override bool Send (IMessage msg)
 
void PublishThingInfo (Thing thing)
 
bool Publish (IMessage msg)
 
void ReceiveData (byte[] data, Participant sender)
 
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.
 
void SendThingInfo (Thing thing)
 

Static Public Member Functions

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

Public Attributes

string name = "ParticipantUDP"
 The name of the participant.
 
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.
 
UdpClient udpClient = null
 The udpClient for this 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 publishIntervalMS = 3000
 The interval in milliseconds for publishing (broadcasting) data on the local network.
 
ulong sendUpdateIntervalMS = 100
 
IPEndPoint endPoint = null
 
string broadcastIpAddress = "255.255.255.255"
 
readonly ConcurrentQueue< IMessagemessageQueue = new ConcurrentQueue<IMessage>()
 
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.
 

Protected Member Functions

override void UpdateMyThings (ulong currentTimeMS)
 
override void UpdateOtherThings (ulong currentTimeMS)
 
override void Process (Participant sender, ParticipantMsg msg)
 
override void Process (Participant sender, NetworkIdMsg msg)
 
void GetBroadcastAddress (IPAddress ip, IPAddress subnetMask)
 
void ReceiveUDP (IAsyncResult result)
 
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)
 
virtual Thing ProcessNewThing (Participant owner, ThingMsg msg, bool isRemote)
 

Protected Attributes

ulong nextPublishMe = 0
 
ulong nextSendUpdate = 0
 

Constructor & Destructor Documentation

◆ SiteServer()

RoboidControl.SiteServer.SiteServer ( int  port = 7681)

Create a new site server.

Parameters
portThe port of which to receive the messages

Member Function Documentation

◆ Update()

override void RoboidControl.SiteServer.Update ( )
virtual

Update all things for this participant.

Reimplemented from RoboidControl.ParticipantUDP.

◆ UpdateMyThings()

override void RoboidControl.SiteServer.UpdateMyThings ( ulong  currentTimeMS)
protectedvirtual

Reimplemented from RoboidControl.ParticipantUDP.

◆ UpdateOtherThings()

override void RoboidControl.SiteServer.UpdateOtherThings ( ulong  currentTimeMS)
protectedvirtual

Reimplemented from RoboidControl.ParticipantUDP.

◆ Process() [1/2]

override void RoboidControl.SiteServer.Process ( Participant  sender,
ParticipantMsg  msg 
)
protectedvirtual

Reimplemented from RoboidControl.ParticipantUDP.

◆ Process() [2/2]

override void RoboidControl.SiteServer.Process ( Participant  sender,
NetworkIdMsg  msg 
)
protectedvirtual

Reimplemented from RoboidControl.ParticipantUDP.

◆ Send()

override bool RoboidControl.ParticipantUDP.Send ( IMessage  msg)
virtualinherited

Reimplemented from RoboidControl.Participant.

◆ GetParticipant() [1/2]

static ParticipantUDP RoboidControl.ParticipantUDP.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 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() [1/2]

static ParticipantUDP RoboidControl.ParticipantUDP.AddParticipant ( string  ipAddress,
int  port,
ParticipantUDP  localParticipant = null 
)
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>

◆ ReplaceLocalParticipant()

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

Replace the local participant.

Parameters
newParticipantThe new local participant

◆ Get()

Thing RoboidControl.Participant.Get ( byte  networkId,
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

Member Data Documentation

◆ ipAddress

string RoboidControl.ParticipantUDP.ipAddress = "0.0.0.0"
inherited

The Ip Address of a participant. When the participant is local, this contains 0.0.0.0.

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

◆ port

int RoboidControl.ParticipantUDP.port = 0
inherited

The port number for UDP communication with the participant. This is 0 for isolated participants.

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

◆ udpClient

UdpClient RoboidControl.ParticipantUDP.udpClient = null
inherited

The udpClient for this participant.

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

◆ isIsolated

bool RoboidControl.ParticipantUDP.isIsolated = false
inherited

True if the participant is running isolated.

Isolated participants do not communicate with other participants