Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    How to convert websocket 2.0 data to readable data

    General Discussion
    0
    1
    29
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sabhanam06 last edited by

      Hi @admin

      I tried updating websocket with websocket 2.0, authentication is successful and able to receive data. While conversion from byte to readable string, data is not able to convert properly.

      Used below code from earlier websocket version. Can you please help

      let strData = atob(evt.data);

                      // Convert binary string to character-number array
                      var charData = strData.split('').map(function (x) { return x.charCodeAt(0); });
      
                      // Turn number array into byte-array
                      var binData = new Uint8Array(charData);
      
                      // Pako magic
                      var result = _atos(pako.inflate(binData));
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post