Git Product home page Git Product logo

wsc's Introduction

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

wsc's People

Contributors

shastel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.