i have a byte array created in c# from object
type and then send it over socket protocol to a Node js app, but unable to deserialize the data to readable object. what is the way to decode this data?
C# serializing code:
private static byte[] ToBytes(object message)
{
IFormatter br = new BinaryFormatter();
byte[] keyAsBytes = null;
using (var ms = new MemoryStream())
{
br.Serialize(ms, message);
keyAsBytes = ms.ToArray();
}
return keyAsBytes;
}
object o = 801507;
byte[] AsBytes = ToBytes(o);
// send AsBytes
And in node js i try to decode the data
function handleMessage(message) {
console.log(message.toString());
}
And the above code print me {"type":"Buffer","data":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,4,1,0,0,0,12,83,121,115,116,101,109,46,73,110,116,54,52,1,0,0,0,7,109,95,118,97,108,117,101,0,9,227,58,12,0,0,0,0,0,11]}
so what is the right way to get the origin value ?