-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
30 lines (25 loc) · 940 Bytes
/
index.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
var StreamRouter = require("stream-router")
, EchoChamber = require("multi-channel-mdm")
, logger = require("mux-demux-logger")
, handleOffer = require("./relays/offer")
, handleAnswer = require("./relays/answer")
module.exports = DiscoveryNetwork
function DiscoveryNetwork(options) {
if (typeof options === "string" || !options) {
options = {
prefix: options || null
}
}
var log = options.log
, prefix = options.prefix || "/discovery"
, router = StreamRouter()
router.addRoute(prefix + "/peer/echo/:streamName", EchoChamber())
router.addRoute(prefix + "/webrtc/echo/:streamName", EchoChamber())
router.addRoute(prefix + "/relay/echo/:streamName", EchoChamber())
router.addRoute(prefix + "/relay/offer", handleOffer)
router.addRoute(prefix + "/relay/answer", handleAnswer)
if (log) {
return logger(router)
}
return router
}