npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

websocket-challenge

v1.2.0

Published

A simple WebSocket competition script for Node.js that uses WebSocket-Node WebSocket server. The challenge is a little contest designed for after-training practice sessions so people can have fun with WebSockets applying their recently acquired knowledge.

Downloads

3

Readme

Dependency Status

Websocket Challenge

A simple WebSocket competition script for Node.js that uses WebSocket-Node WebSocket server. The challenge is a little contest designed for after-training practice sessions so people can have fun with WebSockets applying their recently acquired knowledge.

Installing and running

  1. Clone this repo
  2. Install dependencies with npm install.
  3. Install CoffeeScript if you don't have it: npm install -g coffee-script
  4. Run tests: npm test
  5. Run server: npm start.

Solving the challenge

WebSocket Challenge message protocol is JSON-based, msg field is used to determine message type.

{ "msg":"message" }

Launch the server script.

Think of a cool team/participant name, establish a WebSocket connection and send a challenge_accepted message:

{ "msg": "challenge_accepted", "name": "Socket Masters" }

The server will respond with

{ "msg":"auth", "auth_token":"12a8d3c1" }

which contains an authentication token which you will attach to your messages so the server can identify your team. A very convenient way of WebSocket debugging is through WebSocket Frames panel in Network tab in Google Chrome developer tools.

There're just two simple tasks:

Task #1

Request Task#1 with

{ "msg": "task_one", "auth_token": token }

The server will respond with

{ "msg": "compute", "operands":operands, "operator": operator };

where operands is a two-element array, e.g [3,7] of numbers no bigger than 9 and operator is a string '+' or '*' or '-' which corresponds to an arithmetic operation you have to perform with the operands. Send the result with

{ "msg": "task_one_result", "result":10, "auth_token": token };

Response is either

{ "msg": "win", "text": "" };

where text contains further instructions on how to request Task #2 (so people don't send Task #2 before Task #1) or an error message. All error messages have msg set to "error" so you can handle them separately or just use the WebSocket Frames panel.

Task #2

When you find out how to request Task #2, the server will send you the following message:

{ "msg": "binary_sum", "bits": 8 };

where bits is either 8 or 16. Immediately after that you should receive a binary message (16 bytes) which you should treat as a Uint8Array or Uint16Array depending on the bits field. Your task is to sum the resulting array's elements and send the result:

{ "msg": "task_two_result", "auth_token": token, "result": 462374 }

After that you should receive a confirmation message (or an error message, which shouldn't make you sad, because you have unlimited attempts) which will end the challenge for you and, should you be the first to solve the tasks, declare you the winner (a message will appear in server console)!

That's all for now, there's plenty of room for improvement and extensions though, so your PRs are very welcome :wink:

Contributors (in order of appearance)

Vasiliy Ermolovich
Dzmitry Varabei
Pavel Nosovich