Skip to content

WeGrow/wegrow-challenge-connect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

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.

Instructions

  • 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]

Connect Sequence IMPORTANT

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 a hello event.
  • [server] Sends a team.join event.
  • [client] Sends a team.connect event for a new team.
  • [server] Sends a team.connect event with the websocket URL for the team.
  • [server] Sends a goodbye event when the test is over.

Team Connection

  • [client] Open a websocket to the team using ws_url in team.connect.
  • [server] Sends a hello event.
  • [server] Sends a message event.
  • [server] Sends a team.left event on the team connection.
  • [client] Closes the websocket.

Example Event

{
	"type": "team.connect",
	"team_id": 1,
	"ws_url": "http://localhost:8080/connect/to/team"
}

Global RTM API

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. (use team.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, a team.connect event will be sent to you.
    • team_id

Team RTM API

Server Events

  • hello Sent when the team is connected.
  • pong Sent when a ping event is received.
    • unique_id ping id
  • message
    • text body of the message.

Client Events

  • ping
    • unique_id ping id.

BONUS

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
		}		
	]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published