Created
April 20, 2012 20:05
-
-
Save raytiley/2431445 to your computer and use it in GitHub Desktop.
A simple Carousel RDA Proxy that can turn tags on and off
This file contains hidden or 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 http = require('http'); | |
var net = require('net'); | |
var url = require('url'); | |
//Config Settings | |
var HOST = 'demo.trms.com'; | |
var PORT = 56906; | |
var USERNAME = 'Admin'; | |
var PASSWORD = 'demotrms'; | |
http.createServer(function(req, res) { | |
var reqUrl = url.parse(req.url, true); | |
if(reqUrl.pathname === '/changestatus') { | |
var status = reqUrl.query.status; | |
var tag = reqUrl.query.tag; | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
var command = buildRDACommand(tag, status); | |
sendRDACommand(command); | |
} | |
res.end('Carousel RDA Proxy\n'); | |
}).listen(1337, '127.0.0.1'); | |
console.log('RDA Proxy server running'); | |
function sendRDACommand(command) { | |
var client = new net.Socket(); | |
client.connect(PORT, HOST, function() { | |
console.log('CONNECTED TO: ' + HOST + ':' + PORT); | |
client.write(command); | |
}); | |
client.on('data', function(data) { | |
console.log('DATA: ' + data); | |
client.destroy(); | |
}); | |
client.on('close', function() { | |
console.log('Connection closed'); | |
}); | |
} | |
function buildRDACommand(tag, status) { | |
var command = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; | |
command += "<CarouselCommand xmlns=\"http://www.trms.com/CarouselRemoteCommand\">\n"; | |
command += "<ChangePageStatus>\n"; | |
command += "<UserName>" + USERNAME + "</UserName>\n" | |
command += "<Password>" + PASSWORD + "</Password>\n"; | |
command += "<SelectBulletinTags>\n"; | |
command += "<Tag>" + tag + "</Tag>\n"; | |
command += "</SelectBulletinTags>\n"; | |
command += "<Status>" + status + "</Status>\n"; | |
command += "</ChangePageStatus>\n"; | |
command += "</CarouselCommand>\n"; | |
return command; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment