Frontend Engineer

$120,000*

Begin Challenge Back

Job Description

Remember when you programmed your first piece of useful software? The power and delight you felt when it just... worked? We want to deliver that experience to everyone by giving them the ability to instantly access their games across their favorite screens without friction — Press a button. Play a game.
Build the next big thing

Rainway aims to serve over a billion gamers worldwide by creating new ways for them to access and play their games anywhere, on any device. We have a chance to create the most leveraged gaming service of the last decade. You can help us realize this goal.

Work with some of the best engineers in the world

A team of less than 5 built a product that performs better than services with billions of dollars of R&D. We've achieved more than teams 10x our size by solving problems from first principles and creating our own tech to magnify our output.

Tackle our most interesting and impactful problems

Our team is still small, and people wear many hats. You'd jump between product features, bringing Rainway to a new platform, internal tools — participating in every phase from inception to implementation. Absolutely no boredom.

Apply for this Job

To apply for this job, just solve the given challenge. No long forms.

Begin Challenge

Challenge

At Rainway, we scrape millions of images every single month. For this homework assignment, you will be creating a tool that communicates with our metadata service over a WebSocket to request an image.

The first packet you will need to send is a “resource token request” with these values.

Field Value
Resource ID 61453
TTL 32
Use Cache true

If the metadata service can process your request, you will receive a resource token.

Your mission is simply to display this token as a list of 16 bytes. (In this assignment, you don’t have to worry about using the token to download the image.)


The API uses a binary protocol. This means you’ll receive and send a binary packet over the WebSocket. You will have to encode the values above into an array of bytes. Then, when you get a response, you’ll have to read values back out of an array of bytes.

To connect to the WebSockets metadata service, use the following URL: wss://homework.rain.gg

If malformed or incorrect data is sent to the metadata service, your connection will be terminated.

Rules

  • You may Google as much as you need to but please do not copy-and-paste code.
  • You must complete this task using any language and libraries you like. It can be a console application that connects to the server and displays the token once it has it.

Documentation

Data Types

All data types should be written and read using little-endian byte order.

  • bool: A value that stores either true (1) or false (0). Takes up 1 byte.
  • byte: An unsigned 8-bit integer value. Takes up 1 byte.
  • int32: A signed 32-bit integer value. Takes up 4 bytes.
  • uint32: A unsigned 32-bit integer value. Takes up 4 bytes.
  • uint64: A unsigned 64-bit integer value. Takes up 8 bytes.

byte[] means an array of bytes that lasts until the end of the packet.

Packets

Every packet begins with a unique “packet type” ID (uint32), followed by some fields, as described below.

First, you send a Resource Token Request to the server:

Resource Token Request (ID = 9062)

Name Type Description
Packet Type uint32 The number 9062
Resource ID uint32 A unique identifier for the desired remote resource
TTL byte Sets the amount of time (in minutes) the resource will be available
Use Cache bool Defines whether or not resource downloads will use the CDN

The server will respond with a Resource Token Response:

Resource Token Response (ID = 5291)

Name Type Description
Packet Type uint32 The number 5291
Timestamp uint32 A unix timestamp of when the server began responding
Resource Token uint64 A token that can be used to download this image

This Resource Token is your final answer. Display it on the screen in decimal.


For extra credit, you can complete the rest of the assignment.

Extra Credit

Use your token to send a Download Resource packet and begin a download:

Download Resource (ID: 9414)

Name Type Description
Resource Token uint64 A secure token for accessing and reading a resource

The server will respond with multiple Resource Chunk packets:

Resource Chunk (ID: 4292)

Name Type Description
Group ID uint32 Identifies the group the current chunk belongs to
Index int32 The index of the current chunk in the overall group
Is Last bool Indicates whether the current chunk is the last one
Data byte[] An array of bytes that represents part of a resource

Reassemble the JPEG file from these chunks and save it to disk. What could it be?!

Challenge Solution

Thank you for submitting your solution. We will get back to you as soon as possible.