We're excited you are applying to Unity! As a part of the recruitment process, we would like to validate your technical skills through a small assignment. Return your answer as a zip file containing all relevant files with tests and documentation. Include .git
, so that we can see your commit history.
Do not fork this repository.
Design and implement (with proper tests) a message delivery system using Go, C/C++/C#, or Java (no Java NIO package). You are free to use any external libraries if needed, but make sure your deliverable either contains these or allows us to automatically download any dependencies.
Design the protocol so that it uses a minimal amount of bytes on the wire. The server should consume a minimal amount of resources (memory, cpu, etc.) when processing messages.
In this simplified scenario the message delivery system includes the following parts:
The Hub relays incoming message bodies to receivers based on user ID(s) defined in the message. You don't need to implement authentication, the hub can for example assign arbitrary (unique) user id to the clients as they connect.
- user_id - unsigned 64 bit integer
- Connection to hub must be done using pure TCP. Protocol doesnt require multiplexing.
Clients are users who are connected to the hub. Client may send three types of messages which are described below.
A Client can send an identity message which the hub will respond with the user_id of the connected user.
Client can send a command to list messages, which cause the hub to answer with the list of all connected client user_id:s (excluding the requesting client).
Clients can send relay messages where the body of the message is relayed to the receivers marked in the message.The message body can be relayed to one or multiple receivers.
- max 255 receivers (user_id:s) per message
- message body - byte array (text, JSON, binary, or anything), max length 1024 kilobytes
Relay example: receivers: 2 and 3, body: foobar