Created
August 5, 2011 15:05
-
-
Save joshkehn/1127725 to your computer and use it in GitHub Desktop.
WebSocket - Part 7
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
net.createServer( | |
function(socket) | |
{ | |
/** | |
* Start the flash policy file | |
*/ | |
socket.write("<?xml version=\"1.0\"?>"); | |
socket.write("<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\n"); | |
socket.write("<cross-domain-policy>\n"); | |
/** | |
* Iterating over the domains array | |
*/ | |
domains.forEach( | |
function(domain) | |
{ | |
/** | |
* Break the domain into domain and port values | |
*/ | |
var parts = domain.split(':'); | |
/** | |
* Write them to the socket | |
*/ | |
socket.write("<allow-access-from domain=\""+parts[0]+"\"to-ports=\""+(parts[1]||'80')+"\"/>\n"); | |
} | |
); | |
/** | |
* And we're done | |
*/ | |
socket.write("</cross-domain-policy>\n"); | |
require("sys").log("Wrote policy file."); | |
socket.end(); | |
} | |
).listen(843); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment