forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaphlict_server.js
executable file
·42 lines (33 loc) · 966 Bytes
/
aphlict_server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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);