Created
June 21, 2018 14:26
-
-
Save AcidLeroy/bd90a05e481e35e1378359de6770a905 to your computer and use it in GitHub Desktop.
http with discovery channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
const DC = require('discovery-channel') | |
const crypto = require('crypto') | |
app.get('/', (req, res) => { | |
console.log('Received a request') | |
res.send('Hello World') | |
}) | |
const port = 30000 | |
app.listen(port, () => { | |
console.log('Example app listening on port %s!', port) | |
let channel = DC({dht: true}) // set true to work over internet | |
let id = crypto.createHash('sha256').update(Date()).digest().toString('hex') | |
console.log('The id is =', id) | |
channel.join(id, port) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment