Looks like binary data, you might have some luck parsing it manually with ref-struct. a one byte string doesn't make much sense to me though. On 27 Jan 2013 20:59, "josh" <[email protected]> wrote:
> I need to emit LWES event, and reading about an event structure here > http://www.lwes.org/docs/doxygen/html/structlwes__event.html it looks > like i need 1 byte string, 2 bytes number a struct and a hash of > attributes. > I know about dgram but not sure how to send the correct info in the > socket. any tips? > > // i don't know what should be the structure so i wrote it as json. > var data = { > "name": "my-event", > "url": "my-app.foo.com/register", > "responseTime": "25 ms", > "description": "registration endpoint", > "statusCode": "201" > }; > > var dgram = require('dgram'); > // var data = convertToBinary(data); // I need to find a way to convert > the json to binary > > > var message = new Buffer(data); > var client = dgram.createSocket("udp4"); > > client.send(message, 0, message.length, 12345, "127.0.0.1", function(err, > bytes) { > client.close(); > }); > > > btw, This is an example with Ruby that works: > # test.rb > require 'json' > require 'lwes' # http://lwes.rubyforge.org/LWES/Emitter.html > > emitter = LWES::Emitter.new(:address => '127.0.0.1', :port => 12345) > emitter.emit 'my-event', JSON(ARGF.read) > > This is how I test it: > 1) I listen to events with this command: lwes-event-printing-listener -m > 127.0.0.1 > 2) I run my test.rb with: echo '{"key": "value"}' | ruby test.rb > 3) I see this in the console of the listener: > my-event[4] > { > SenderPort = 63162; > key = value; > ReceiptTime = 1359274824724; > SenderIP = 127.0.0.1; > } > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
