projects
/
henge
/
kiak.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
need to do ICE step
[henge/kiak.git]
/
main.js
diff --git
a/main.js
b/main.js
index
f123a41
..
35cffef
100644
(file)
--- a/
main.js
+++ b/
main.js
@@
-25,15
+25,6
@@
const router = {
httpd: undefined,
wsProtocol: opts['no-tls'] ? 'ws' : 'wss',
respond: (request,response) => {
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) => {
console.log('server handling request')
const serveFile = (fPath) => {
fs.readFile(fPath, { encoding: 'utf8' }, (err, data) => {
@@
-82,9
+73,15
@@
const router = {
// (this happens when a client connects to an active route with no currently-online host)
}
else { /* Client sent offer, waiting for answer */
// (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) => {
route.socket.on('message', (hostResponse) => {
+ console.log('Server: Sending host answer to client')
console.log(hostResponse)
console.log(hostResponse)
+ response.writeHead(200, { 'Content-Type': 'application/json' })
+ response.write(hostResponse)
+ response.end()
+
})
}
})
}