-
Notifications
You must be signed in to change notification settings - Fork 1
Communication
The client and server need to communicate with each other. This page documents those particulars.
The client and server communicate over websockets.
The client informs the server that a team wants to spawn some boids. The server should update it's simulation accordingly.
The client will send a the server a message containing the following JSON to indicate that team-name wishes to spawn new boids.
{
"Spawn": { "team": "`team-name`" }
}The server informs the client of the current state of the simulation and status of registered brain-servers. We will give a examplar message and discuss each part below.
{
"teams": {
"`team-a`": {
"name": "`team-a`",
"connected": "true",
"flock": {
"boids": {
"`boid-a`": {
"x": "0.37",
"y": "0.51",
"heading": "0.0",
"speed": "0.01"
}
}
}
}
}
}One can argue that the above structure is the most economical. We are optimizing for ease of development on the server-side. Besides that, this allows the JSON to be expanded without breaking the client.
For the moment it contains a single property teams that describe all registered teams.
The teams property describes the teams that registered to the server. Teams are identified by their team name. So the teams object maps each team name to the information about that team.
Each team contain the following properties
-
name: The name the team used to register itself to the server. -
connected: The connection status of the team. This is a boolean that is determined by how the teams brain-server responds to the heartbeat. -
flock: A detailed description of the teams flock.
Each flock contains a property boids that describes each boid in the flock.
The boids property describes all the boids that make up the flock. Each boid has a automatically generated nickname that uniquely identifies the boid in the flock.
Each nickname maps to a description of the corresponding boid.
Each boid has the following properties
-
x: The x-coordinate of the boid in the world. -
y: The y-coordinate of the boid in the world. -
heading: The boids heading. -
speed: The boids speed.
For more information on these characteristics, see the book.