Honours Project Development Blog – s2 – 9

After completing an initial draft of my methodology, I was keen to get back into development. I begun by trialling my locally functioning deployment in the cloud. As far as the improbable inspector was concerned, the simulation ran fine. However, whenever I tried to connect a client it would connect for a few seconds before going blank and losing its connection to SpatialOS. I found that the request to spawn a player was being returned unsuccessful and after a certain number of failed attempts the client was just being disconnected. To solve this issue, I had to delve into the client connection lifecycle of a SpatialOS application, which until this point I had not needed to understand.

The offending code was in the bootstrap script which handles the initial connection to the deployment. A query was being sent without setting a timeout value. The timeout parameter defaults to ‘timeout = null’ which I initially assumed meant that the query would not timeout and would wait indefinitely for a response. This assumption was incorrect, by setting the timeout to an arbitrarily high value (20.0 seconds), I could make the query wait out the latency and return correctly, successfully spawning a player.

I realised that this would affect all queries and so my ui query/command system would not reliably work in this way. I decided to instead attach a ‘CellSync’ mono behaviour to each cell which was visible to the client. When the reset button is now pressed, the client finds all game objects with a CellSync component and sets them to be reset. This script uses a regular component update to set the cells to be reset. The cells wait in their reset state until the start button is pressed on the ui which uses a similar process to start the cells performing their calculations again.

ui0

No I was no longer using the query command system, and due to an issue I noticed with player spawning, I decided to move the ui off the player entity and instead have it as a part of the client. I noticed that sometimes the application would continue to spawn players even though only one client had connected, and this would need a fix.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s