The goal of this program is to manage a set of bot connections for individual teams. Your program will be measured by its resiliency, clarity, and design.
There are two types of connections: Global and Team. The Global connection is used to manage team connections (team.join
, team.left
, team.connect
are all sent over the global connection). Team connections are used for methods and events that are specific to an individual team. There's one websocket connection for the Global connection and one websocket connection for each Team connection.
To start, open a web socket connection to the Global API and keep team connections alive :) And don't forget, have fun.
- Download this repo.
- Build a client that connects to the global api and maintains connections for new teams (The global connection is made within index.js for you).
- Once you've completed, zip up your work and send it to [email protected]
NOTE: [server]
Denotes an event generated by the server.
NOTE: [client]
Denotes an event generated by the client you're building.
Global Connection
[client]
Open a websocket to/global
.[server]
Sends ahello
event.[server]
Sends ateam.join
event.[client]
Sends ateam.connect
event for a new team.[server]
Sends ateam.connect
event with the websocket URL for the team.[server]
Sends agoodbye
event when the test is over.
Team Connection
[client]
Open a websocket to the team usingws_url
inteam.connect
.[server]
Sends ahello
event.[server]
Sends amessage
event.[server]
Sends ateam.left
event on the team connection.[client]
Closes the websocket.
{
"type": "team.connect",
"team_id": 1,
"ws_url": "http://localhost:8080/connect/to/team"
}
NOTE: Server Events are sent to you. Client Events are sent by you.
Server Events
hello
sent when the global connection is opened.goodbye
sent when the global connection is closed.team.join
sent when a team joins. (useteam.connect
to connect to this team).team_id
team.left
sent when a team disconnects.team_id
team.connect
sent when a team connection is ready to be made.ws_url
websocket url used to connect to the team.team_id
error
message
details about the error.received_message
message sent by the client.team_id
Client Events
team.connect
send this to connect a team. When a team is ready, ateam.connect
event will be sent to you.team_id
Server Events
hello
Sent when the team is connected.pong
Sent when aping
event is received.unique_id
ping id
message
text
body of the message.
Client Events
ping
unique_id
ping id.
To go above and beyond, handle the healthcheck
event. This event is sent over the Global connection. When you receive it, send back a healthcheck
event with the state of your teams.
Here's an example healthcheck
event sent by your client:
{
type: "healthcheck",
stats: [
{
id: 1, // team id
connected: true, // true if the websocket is connected.
message_count: 100, // total # of messages received by the team.
props_count: 10 // total # of messages received by the team w/ "props" in the text.
},
{
id: 2,
connected: false,
message_count: 99,
props_count: 9
}
]
}