Difference between revisions of "Node"

From Open Rail Data Wiki
Jump to navigation Jump to search
m (categorisation)
Line 18: Line 18:
 
});
 
});
 
</pre>
 
</pre>
 +
 +
[[Category:Network Rail Data Feeds]]

Revision as of 09:04, 20 May 2013

node.js

Remember to enable the feed you are trying to subscribe in the network rail web application.

 
var prettyjson = require('prettyjson'),
    StompClient = require('stomp-client').StompClient;

var destination = '/topic/TRAIN_MVT_ALL_TOC',
    client = new StompClient('datafeeds.networkrail.co.uk', 61618, 'emailaddress', 'your_password', '1.0');

client.connect(function(sessionId) {
    console.log('Trying to connect...');
    client.subscribe(destination, function(body, headers) {
        console.log(prettyjson.render(JSON.parse(body)));
    });
});