Skip to content
WebSocket Challenge
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.vsworkflows Integrate vsworkflows and add vorkflow example (#82) Jun 19, 2017
client
config Save store to mongoDB (#42) Dec 3, 2016
server
shared Base server refactoring (#86) Sep 18, 2017
.babelrc Simple integration of pm2 May 13, 2017
.editorconfig add editor config Sep 10, 2016
.eslintrc
.gitignore Base server refactoring (#86) Sep 18, 2017
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Jun 19, 2017
CONTRIBUTING.md Create CONTRIBUTING.md Jun 19, 2017
LICENSE Create LICENSE Jun 19, 2017
README.md Update README.md May 15, 2019
bootstrap.js Use initialize hook instead of babel-node Dec 3, 2016
ecosystem.config.js Simple integration of pm2 May 13, 2017
index.js Save store to mongoDB (#42) Dec 3, 2016
nodemon.json Add wathc option to nodemon.json Dec 3, 2016
package.json Add 'function evaluation' task (#98) Nov 27, 2018
webpack.config.base.js Add entry point for shared codebase Jun 22, 2017
webpack.config.dev.js Migrate to webpack2 (#76) Apr 9, 2017
webpack.config.js Migrate to webpack2 (#76) Apr 9, 2017
webpack.config.prod.js
yarn.lock

README.md

WebSocket Challenge

Solving the challenge:

  1. Create WebSocket and set binaryType = "arraybuffer";

  2. Registration:

    /** Think about cool participant name and then send a registration message **/
    
    { "name":"SuperHero", "command": "challenge accepted" }
  3. The server will respond with:

    /** 
       Message contains an authentication token which you will attach to your messages 
       for identification and the next task name.
    **/
    {"message":"You successfully accept challenge","next":"arithmetic","token":"eae34860c6f507f2"}
  4. Request the next task with:

    { "token": my_saved_token, "command": saved_next_task_name }

    There are 3 simple tasks:

    {"name":"arithmetic","task":{"sign": OPERATION ,"values": ARRAY}}
       
    /**
        where:
        ARRAY {Array}        numbers array, length = 4;
        OPERATION {String}   random operator (+, -, *) which corresponds to an arithmetic operation 
                             you have to perform with ARRAY values
    
        and then send answer with:
    **/  
    { "token": my_saved_token, "command": "arithmetic", "answer": RESULT }
    /** if answer is correct, server will respond with: **/
       
    { "message":"You solve task","nextTask":"function_evaluation" }
       
     /** request the next task with: **/
    
    { "token": my_saved_token, "command": saved_next_task_name }
       

    2nd task:

       
    /** Server will send you the following message **/
       
    { "name":"function_evaluation","task": { "fn": STRING } }
    
    /** where STRING is String representation of function.
        ---------------------------------------------
        you have to somehow execute this function and send it's result 
    **/
    
    { "token": my_saved_token, "command": "function_evaluation", "answer": RESULT }
    /** if RESULT is correct, server will respond with **/
    
    { "message": "You solve task", "nextTask": "binary_arithmetic" }
    

    3nd task:

       
    /** Server will send you the following message **/
       
    { "name":"binary_arithmetic","task": { "bits": BITS} }
    
    /** 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: 
    **/
    
    { "token": my_saved_token, "command": "binary_arithmetic", "answer": RESULT }
    /** if RESULT is correct, server will respond with **/
    
    { "message": "You solve task", "nextTask":"win" }
    

    And finish the challenge!

    /** Request the win! **/
       
    { "token": my_saved_token, "command": "win" }
  5. Send the uniq code

You can’t perform that action at this time.