File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const protobuf = require ( "protobufjs" ) ;
21const COMMON_TYPE = 0 ;
32const WINDOWSIZE_TYPE = 1 ;
4- const protofile = "channelmsg.proto" ;
5- /*
6- protobuf.load("channelmsg.proto", function(err, root) {
7- if (err)
8- throw err;
9-
10- // Obtain a message type
11- const MsgSchema = root.lookupType("jobmgr.CommonMsg");
12-
13- // Exemplary payload
14- let payload = { id: 0, content: "" };
15-
16- // Verify the payload if necessary (i.e. when possibly incomplete or invalid)
17- let errMsg = MsgSchema.verify(payload);
18- if (errMsg)
19- throw Error(errMsg);
20-
21- // Create a new message
22- let msg = MsgSchema.create(payload); // or use .fromObject if conversion is necessary
23- console.log(msg)
24- // Encode a message to an Uint8Array (browser) or Buffer (node)
25- let buffer = MsgSchema.encode(msg).finish();
26- // ... do something with buffer
27- console.log(buffer)
28-
29- // Decode an Uint8Array (browser) or Buffer (node) to a message
30- let message = MsgSchema.decode(buffer);
31- // ... do something with message
32- console.log(message)
33- // If the application uses length-delimited buffers, there is also encodeDelimited and decodeDelimited.
34-
35- // Maybe convert the message back to a plain object
36- var object = AwesomeMessage.toObject(message, {
37- longs: String,
38- enums: String,
39- bytes: String,
40- // see ConversionOptions
41- });
42- });
43- */
443
454function commonMsg ( data ) {
465 return '1' + data ;
You can’t perform that action at this time.
0 commit comments