Nearly every API returns an object. arrays, strings, functions, etc... how does that data get sent across from the server to the client?My end goal is to pass an array of strings from a nodejs "application server" using the net module over to a C++ desktop application.Trying to figure it out conceptually in node.js on both client and server first, so.. here's what I have:server.js:setInterval(() => { let testArr = ["first", "second", "third"]; connectedClients.forEach((client) => { client.write(testArr); }); }, 2000); client.js:client.on("data", (data) => { data.forEach((element) => console.log(element.toString())); //console.log(`Message received from server: ${data}`); }); I've also tried passing in regular strings instead of arrays, and decoding whatever's returned from hex back to the actual value.. But I don't think it's a hex according to my debugger.All I want is my stupid object accessible in the C++ app. Am I way off track? I've been fucking around with Buffers for a few hours and I'm not making any progress.
Submitted September 02, 2020 at 07:17PM by fastpenguin91
No comments:
Post a Comment