mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 02:43:50 +00:00
event cucle (#76)
* install sass * refact: integration settings - OSC in its own HTTP endpoint - OSC settings have own object in db * refact: simplify event cycle * refact: restructure external triggers http * refact: restructure external triggers osc+socket * refact: restructure data updates * feat: osc integration class * IO improvements - timer uses osc integration - create trigger handler to manage external triggers * refact: refract state machine update * Integration: simple HTTP Client * Integration: http options in datamodel * Integration: call http send on life cycle * feat/62-logging: fix issue #71
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/** Class contains logic towards outgoing HTTP communications. */
|
||||
import * as http from 'http';
|
||||
|
||||
export class HTTPIntegration {
|
||||
|
||||
constructor() {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description Initializes oscClient
|
||||
* @param {object} httpConfig - Http configurations options
|
||||
*/
|
||||
init(httpConfig) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sends http get request from predefined messages
|
||||
* @param {string} path - complete http path
|
||||
*/
|
||||
async send(path) {
|
||||
if (path == null) {
|
||||
console.log('HTTP ERROR: Message undefined');
|
||||
return;
|
||||
}
|
||||
|
||||
const options = new URL(path);
|
||||
let str = '';
|
||||
|
||||
const req = http.request(options, res => {
|
||||
console.log(`statusCode: ${res.statusCode}`)
|
||||
|
||||
res.on('data', function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
|
||||
res.on('end', function () {
|
||||
console.log(str);
|
||||
});
|
||||
})
|
||||
|
||||
req.on('error', error => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.end()
|
||||
}
|
||||
|
||||
shutdown() { /* Nothing to shutdown */ }
|
||||
}
|
||||
Reference in New Issue
Block a user