mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
43 lines
966 B
JavaScript
43 lines
966 B
JavaScript
|
var net = require('net');
|
||
|
|
||
|
function getFlashPolicy() {
|
||
|
return [
|
||
|
'<?xml version="1.0"?>',
|
||
|
'<!DOCTYPE cross-domain-policy SYSTEM ' +
|
||
|
'"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">',
|
||
|
'<cross-domain-policy>',
|
||
|
'<allow-access-from domain="*" to-ports="*"/>',
|
||
|
'</cross-domain-policy>'
|
||
|
].join("\n");
|
||
|
}
|
||
|
|
||
|
net.createServer(function(socket) {
|
||
|
socket.on('data', function() {
|
||
|
socket.write(getFlashPolicy() + '\0');
|
||
|
});
|
||
|
}).listen(843);
|
||
|
|
||
|
var sp_server = net.createServer(function(socket) {
|
||
|
function xwrite() {
|
||
|
var data = {hi: "hello"};
|
||
|
var serial = JSON.stringify(data);
|
||
|
|
||
|
var length = Buffer.byteLength(serial, 'utf8');
|
||
|
length = length.toString();
|
||
|
while (length.length < 8) {
|
||
|
length = "0" + length;
|
||
|
}
|
||
|
|
||
|
socket.write(length + serial);
|
||
|
|
||
|
console.log('write : ' + length + serial);
|
||
|
}
|
||
|
|
||
|
socket.on('connect', function() {
|
||
|
|
||
|
xwrite();
|
||
|
setInterval(xwrite, 1000);
|
||
|
|
||
|
});
|
||
|
}).listen(2600);
|