Created
November 15, 2013 14:36
-
-
Save nunogmartins/7485247 to your computer and use it in GitHub Desktop.
More code help to understand the issue in the protobuffers to retrieve more than one byte field from a message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Protobuf = require('protobufjs'); | |
var myparser = require("./protobuf/myparser"); | |
var builder = Protobuf.protoFromFile("./protobuf/protobuffer.proto"); | |
var MessageBuilder = builder.build("Message"); | |
// cdata is received from a socket | |
var decodedm = MessageBuilder.decode(cdata); | |
var data = decodedm; | |
var servm = data.servm; | |
var message_data = { }; | |
if (servm) { | |
if (servm.servreq) { | |
message_data = { | |
"nodeid" : servm.servreq.nodeid.toHex(), | |
"tokens": servm.servreq.tokens, | |
"promise_of_payment" : servm.servreq.promise_of_payment.toHex(), | |
"pubk" : servm.servreq.pubk.toHex(), | |
"cryptoid" : data.servm.servreq.cryptoid.toHex(), | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment