Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error detection for the flashSocket net server #69

Merged
1 commit merged into from
Oct 6, 2010
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions lib/socket.io/transports/flashsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ Flashsocket.init = function(listener){

try {
netserver = net.createServer(function(socket){
socket.addListener("error",function(err){
console.log("Socket.io::netserver request error: " + JSON.stringify(err)); socket.end && socket.end() || socket.destroy && socket.destroy();
});
socket.write('<?xml version="1.0"?>\n');
socket.write('<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">\n');
socket.write('<cross-domain-policy>\n');
socket.addListener("error",function(err){
socket.end && socket.end() || socket.destroy && socket.destroy();
});
var xml = '<?xml version="1.0"?>\n<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">\n<cross-domain-policy>\n';

listeners.forEach(function(l){
[].concat(l.options.origins).forEach(function(origin){
var parts = origin.split(':');
socket.write('<allow-access-from domain="' + parts[0] + '" to-ports="'+ parts[1] +'"/>\n');
});
});
listeners.forEach(function(l){
[].concat(l.options.origins).forEach(function(origin){
var parts = origin.split(':');
xml += '<allow-access-from domain="' + parts[0] + '" to-ports="'+ parts[1] +'"/>\n';
});
});

socket.write('</cross-domain-policy>\n');
socket.end();
});
netserver.addListener("error",function(err){
console.log("Socket.io::netserver global error: " + JSON.stringify(err));
});
netserver.listen(843);
xml += '</cross-domain-policy>\n';

if(socket && socket.readyState == 'open'){
socket.write(xml);
socket.end();
}
});
netserver.addListener("error",function(err){});
netserver.listen(843);
} catch(e){
if (e.errno == 13){
console.error("\x1B[1;31m" + [
Expand Down