Skip to content

21-23/wsc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

May 16, 2019
6ffec96 · May 16, 2019
Oct 25, 2016
Jun 19, 2017
May 16, 2019
Dec 3, 2016
May 15, 2019
Sep 18, 2017
May 13, 2017
Sep 10, 2016
Nov 20, 2016
Sep 18, 2017
Jun 19, 2017
Jun 19, 2017
Jun 19, 2017
May 15, 2019
Dec 3, 2016
May 13, 2017
Dec 3, 2016
Dec 3, 2016
Nov 27, 2018
Jun 22, 2017
Apr 9, 2017
Apr 9, 2017
May 21, 2018
Nov 27, 2018

Repository files navigation

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

About

WebSocket Challenge

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published