httpd: undefined,
wsProtocol: opts['no-tls'] ? 'ws' : 'wss',
respond: (request,response) => {
- let body = []
- request.on('error', function(err) {
- console.error(`error is ${err}`);
- }).on('data', function(chunk) {
- console.log(`chunk is ${chunk}`)
- body.push(chunk);
- }).on('end', function() {
- console.log(`body is ${body}`)
- })
console.log('server handling request')
const serveFile = (fPath) => {
fs.readFile(fPath, { encoding: 'utf8' }, (err, data) => {
// (this happens when a client connects to an active route with no currently-online host)
}
else { /* Client sent offer, waiting for answer */
- console.log(JSON.parse(request.headers['x-strapp-type']))
+ console.log('Server: Sending client offer to host')
+ route.socket.send(request.headers['x-strapp-type'])
route.socket.on('message', (hostResponse) => {
+ console.log('Server: Sending host answer to client')
console.log(hostResponse)
+ response.writeHead(200, { 'Content-Type': 'application/json' })
+ response.write(hostResponse)
+ response.end()
+
})
}