forked from telefonicaid/iotagent-node-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecho.js
32 lines (26 loc) · 926 Bytes
/
echo.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
var http = require('http'),
express = require('express');
function dummyResponse(req, res) {
console.log('Processing response to [%s] [%s] [%j]', req.method, req.path, req.query);
res.status(200).send('89');
}
function initEcho(callback) {
echoServer = {
server: null,
app: express(),
router: express.Router()
};
echoServer.app.set('port', 9999);
echoServer.app.set('host', '0.0.0.0');
echoServer.router.get('/iot/d', dummyResponse);
echoServer.server = http.createServer(echoServer.app);
echoServer.app.use('/', echoServer.router);
echoServer.server.listen(echoServer.app.get('port'), echoServer.app.get('host'), callback);
}
initEcho(function (error) {
if (error) {
console.log('Could not initialize echo server: %s', error);
} else {
console.log('Echo server started successfully');
}
});