Skip to content
Browse files

dead code begone

  • Loading branch information...
1 parent dccbedd commit d31b4847d474908343d50a687875e687e0004fa4 @Raynos committed Aug 17, 2012
Showing with 0 additions and 162 deletions.
  1. +0 −34 lib/connection.js
  2. +0 −14 lib/index.js
  3. +0 −1 lib/log.js
  4. +0 −37 lib/peerNetwork.js
  5. +0 −76 lib/webRTCNetwork.js
View
34 lib/connection.js
@@ -1,34 +0,0 @@
-var shoe = require("shoe")
- , MuxDemux = require("mux-demux")
- , EventEmitter = require("events").EventEmitter
- , uuid = require("node-uuid")
-
-module.exports = Connection
-
-function Connection(uri, networkName) {
- networkName = networkName || "/discovery"
-
- console.log("opening shoe on ", uri)
- var stream = shoe(uri || "/shoe")
- , mx = MuxDemux()
- , conn = new EventEmitter()
-
- stream.pipe(mx).pipe(stream)
-
- conn.networkName = networkName
- conn.identify = identify
- conn.mx = mx
- conn.stream = stream
-
- stream.once("end", conn.emit.bind(conn, "end"))
- stream.once("connect", conn.emit.bind(conn, "connect"))
-
- return conn
-
- function identify(user) {
- if (!user) {
- user = uuid()
- }
- conn.selfId = user.toString()
- }
-}
View
14 lib/index.js
@@ -1,14 +0,0 @@
-// God damn
-window.Buffer = require("buffer").Buffer
-
-var Connection = require("./connection")
- , PeerNetwork = require("./peerNetwork")
- , WebRTCNetwork = require("./webRTCNetwork")
- , log = require("./log")
-
-module.exports = {
- Connection: Connection
- , PeerNetwork: PeerNetwork
- , WebRTCNetwork: WebRTCNetwork
- , log: log
-}
View
1 lib/log.js
@@ -1 +0,0 @@
-module.exports = require("browser-log").create()
View
37 lib/peerNetwork.js
@@ -1,37 +0,0 @@
-var RemoteEventEmitter = require("remote-events")
- , EventEmitter = require("events").EventEmitter
- , log = require("./log")
-
-module.exports = PeerNetwork
-
-function PeerNetwork(connection) {
- var mx = connection.mx
- , networkName = connection.networkName
- , localPeerId = connection.selfId
- , peerStream = mx.createStream(networkName + "/peer/echo")
- , peerEmitter = new RemoteEventEmitter()
- , network = new EventEmitter()
-
- peerStream.pipe(peerEmitter.getStream()).pipe(peerStream)
-
- peerEmitter.on("peer", onpeer)
-
- network.join = join
-
- return network
-
- function onpeer(remotePeerId) {
- log.info("onpeer", remotePeerId)
- if (remotePeerId !== localPeerId) {
- network.emit("peer", remotePeerId)
- }
- }
-
- function join(user) {
- log.info("join", user)
- if (user) {
- localPeerId = user.toString()
- }
- peerEmitter.emit("peer", localPeerId)
- }
-}
View
76 lib/webRTCNetwork.js
@@ -1,76 +0,0 @@
-var RemoteEventEmitter = require("remote-events")
- , EventEmitter = require("events").EventEmitter
- , log = require("./log")
- , SessionDescription = window.SessionDescription
- , IceCandidate = window.IceCandidate
-
-module.exports = WebRTCNetwork
-
-function WebRTCNetwork(connection) {
- var mx = connection.mx
- , networkName = connection.networkName
- , localPeerId = connection.selfId
- , webrtcStream = mx.createStream(networkName + "/webrtc/echo")
- , webrtcEmitter = new RemoteEventEmitter()
- , network = new EventEmitter()
-
- webrtcStream.pipe(webrtcEmitter.getStream()).pipe(webrtcStream)
-
- webrtcEmitter.on("offer", onoffer)
- webrtcEmitter.on("answer", onanswer)
- webrtcEmitter.on("candidate", oncandidate)
-
- network.sendOffer = sendOffer
- network.sendAnswer = sendAnswer
- network.sendCandidate = sendCandidate
-
- network.identify = identify
-
- return network
-
- function onoffer(toPeerId, fromPeerId, offer) {
- log.verbose("onoffer", arguments)
- if (toPeerId === localPeerId) {
- network.emit("offer", fromPeerId, new SessionDescription(offer))
- }
- }
-
- function onanswer(toPeerId, fromPeerId, answer) {
- log.verbose("onanswer", arguments)
- if (toPeerId === localPeerId) {
- network.emit("answer", fromPeerId, new SessionDescription(answer))
- }
- }
-
- function oncandidate(toPeerId, fromPeerId, candidate) {
- log.silly("oncandidate", arguments)
- if (toPeerId === localPeerId) {
- network.emit("candidate", fromPeerId
- , new IceCandidate(candidate.label, candidate.candidate))
- }
- }
-
- function sendOffer(remotePeerId, offer) {
- log.info("sendOffer", arguments)
- // sending an offer
- webrtcEmitter.emit("offer", remotePeerId, localPeerId, offer.toSdp())
- }
-
- function sendAnswer(remotePeerId, answer) {
- log.info("sendAnswer", arguments)
-
- webrtcEmitter.emit("answer", remotePeerId, localPeerId, answer.toSdp())
- }
-
- function sendCandidate(remotePeerId, candidate) {
- log.silly("candidate", arguments)
- webrtcEmitter.emit("candidate", remotePeerId, localPeerId, {
- label: candidate.label
- , candidate: candidate.toSdp()
- })
- }
-
- function identify(user) {
- localPeerId = user.toString()
- }
-}

0 comments on commit d31b484

Please sign in to comment.
Something went wrong with that request. Please try again.