Changeset View
Changeset View
Standalone View
Standalone View
support/aphlict/server/aphlict_server.js
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | console.log( | ||||
| "port 843 to start a Flash policy server. It will downgrade to run as a " + | "port 843 to start a Flash policy server. It will downgrade to run as a " + | ||||
| "less-privileged user after binding if you pass a user in the command " + | "less-privileged user after binding if you pass a user in the command " + | ||||
| "line arguments with '--user=alincoln'."); | "line arguments with '--user=alincoln'."); | ||||
| process.exit(1); | process.exit(1); | ||||
| } | } | ||||
| var net = require('net'); | var net = require('net'); | ||||
| var http = require('http'); | var http = require('http'); | ||||
| var url = require('url'); | |||||
| process.on('uncaughtException', function(err) { | process.on('uncaughtException', function(err) { | ||||
| debug.log("\n<<< UNCAUGHT EXCEPTION! >>>\n" + err.stack); | debug.log('\n<<< UNCAUGHT EXCEPTION! >>>\n' + err.stack); | ||||
| process.exit(1); | process.exit(1); | ||||
| }); | }); | ||||
| var flash_server = new JX.AphlictFlashPolicyServer() | var flash_server = new JX.AphlictFlashPolicyServer() | ||||
| .setDebugLog(debug) | .setDebugLog(debug) | ||||
| .setAccessPort(config.port) | .setAccessPort(config.port) | ||||
| .start(); | .start(); | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | request.on('end', function() { | ||||
| } catch (err) { | } catch (err) { | ||||
| response.statusCode = 400; | response.statusCode = 400; | ||||
| response.write('400 Bad Request'); | response.write('400 Bad Request'); | ||||
| } finally { | } finally { | ||||
| response.end(); | response.end(); | ||||
| } | } | ||||
| }); | }); | ||||
| } else if (request.url == '/status/') { | } else if (request.url == '/status/') { | ||||
| request.on('data', function(data) { | request.on('data', function() { | ||||
| // We just ignore the request data, but newer versions of Node don't | // We just ignore the request data, but newer versions of Node don't | ||||
| // get to 'end' if we don't process the data. See T2953. | // get to 'end' if we don't process the data. See T2953. | ||||
| }); | }); | ||||
| request.on('end', function() { | request.on('end', function() { | ||||
| var status = { | var status = { | ||||
| 'uptime': (new Date().getTime() - start_time), | 'uptime': (new Date().getTime() - start_time), | ||||
| 'clients.active': clients.getActiveListenerCount(), | 'clients.active': clients.getActiveListenerCount(), | ||||
| 'clients.total': clients.getTotalListenerCount(), | 'clients.total': clients.getTotalListenerCount(), | ||||
| 'messages.in': messages_in, | 'messages.in': messages_in, | ||||
| 'messages.out': messages_out, | 'messages.out': messages_out, | ||||
| 'log': config.log, | 'log': config.log, | ||||
| 'version': 6 | 'version': 6 | ||||
| }; | }; | ||||
| response.writeHead(200, {'Content-Type': 'text/plain'}); | response.writeHead(200, {'Content-Type': 'text/plain'}); | ||||
| response.write(JSON.stringify(status)); | response.write(JSON.stringify(status)); | ||||
| response.end(); | response.end(); | ||||
| }); | }); | ||||
| } else { | } else { | ||||
| response.statusCode = 400; | response.statusCode = 400; | ||||
| response.write('400 Bad Request'); | response.write('400 Bad Request'); | ||||
| response.end(); | response.end(); | ||||
| } | } | ||||
| }).listen(config.admin, config.host); | }).listen(config.admin, config.host); | ||||
| function transmit(msg) { | function transmit(msg) { | ||||
| var listeners = clients.getListeners().filter(function(client) { | var listeners = clients.getListeners().filter(function(client) { | ||||
| return client.isSubscribedToAny(msg.subscribers); | return client.isSubscribedToAny(msg.subscribers); | ||||
| }); | }); | ||||
| for (var i = 0; i < listeners.length; i++) { | for (var i = 0; i < listeners.length; i++) { | ||||
| Show All 21 Lines | |||||