From 9dc03831a09029d8780470dad6926c6fd7359683 Mon Sep 17 00:00:00 2001 From: "S. Li" Date: Mon, 20 Jul 2015 12:20:46 -0500 Subject: [PATCH] tidy up the webrtc code; move stream dependency to core --- .meteor/packages | 1 + packages/rocketchat-webrtc-ib/common.js | 1 - packages/rocketchat-webrtc-ib/package.js | 5 +--- packages/rocketchat-webrtc-ib/server.js | 18 --------------- packages/rocketchat-webrtc-ib/webrtc.js | 2 -- .../rocketchat-webrtc-ib/webrtcmsg.coffee | 23 ------------------- packages/rocketchat-webrtc/package.js | 3 +-- server/stream/streamBroadcast.coffee | 10 +++++--- 8 files changed, 10 insertions(+), 53 deletions(-) delete mode 100644 packages/rocketchat-webrtc-ib/common.js delete mode 100644 packages/rocketchat-webrtc-ib/server.js diff --git a/.meteor/packages b/.meteor/packages index 29466fdfc1b6..3600d7e3e689 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -59,4 +59,5 @@ yasaricli:slugify meteorhacks:kadira meteorhacks:flow-router meteorhacks:flow-layout +arunoda:streams@0.1.17 rocketchat:webrtc diff --git a/packages/rocketchat-webrtc-ib/common.js b/packages/rocketchat-webrtc-ib/common.js deleted file mode 100644 index a4cd85fd3604..000000000000 --- a/packages/rocketchat-webrtc-ib/common.js +++ /dev/null @@ -1 +0,0 @@ -stream = new Meteor.Stream('webrtc'); \ No newline at end of file diff --git a/packages/rocketchat-webrtc-ib/package.js b/packages/rocketchat-webrtc-ib/package.js index efe2d7fefdd5..b8bbd56582db 100644 --- a/packages/rocketchat-webrtc-ib/package.js +++ b/packages/rocketchat-webrtc-ib/package.js @@ -10,15 +10,12 @@ Package.onUse(function(api) { api.use([ 'coffeescript', - 'rocketchat:lib@0.0.1', - 'arunoda:streams@0.1.17' + 'rocketchat:lib@0.0.1' ]); - api.addFiles('common.js'); api.addFiles('adapter.js', ['client']); api.addFiles('webrtc.js', ['client']); api.addFiles('webrtcmsg.coffee', ['client']); - api.addFiles('server.js', ['server']); api.export('webrtc') }); diff --git a/packages/rocketchat-webrtc-ib/server.js b/packages/rocketchat-webrtc-ib/server.js deleted file mode 100644 index d305ebe10c57..000000000000 --- a/packages/rocketchat-webrtc-ib/server.js +++ /dev/null @@ -1,18 +0,0 @@ -webrtc = { - stream: stream -} - -stream.permissions.write(function(eventName) { - console.log('stream.permissions.write', this.userId); - return eventName == 'send' && this.userId; -}); - -stream.permissions.read(function(eventName) { - console.log('stream.permissions.read', this.userId, eventName); - return this.userId == eventName; -}); - -stream.on('send', function(data) { - console.log('send', data); - stream.emit(data.to, data); -}); \ No newline at end of file diff --git a/packages/rocketchat-webrtc-ib/webrtc.js b/packages/rocketchat-webrtc-ib/webrtc.js index c20e9759981b..55bc918c263d 100644 --- a/packages/rocketchat-webrtc-ib/webrtc.js +++ b/packages/rocketchat-webrtc-ib/webrtc.js @@ -12,7 +12,6 @@ webrtc = { {url: "stun:stun.l.google.com:19302"} ] }, - stream: stream, send: function(data) { console.log data.to = webrtc.to; @@ -24,7 +23,6 @@ webrtc = { msg: JSON.stringify(data), rid: webrtc.room }); - // stream.emit('send', data); }, stop: function(sendEvent) { diff --git a/packages/rocketchat-webrtc-ib/webrtcmsg.coffee b/packages/rocketchat-webrtc-ib/webrtcmsg.coffee index 1a3f1ccfbf8c..3bfbbd751b31 100644 --- a/packages/rocketchat-webrtc-ib/webrtcmsg.coffee +++ b/packages/rocketchat-webrtc-ib/webrtcmsg.coffee @@ -3,29 +3,6 @@ class IncomingRtcMessageProcessor if (message.to == Meteor.userId()) if (message.ts > webrtc.lastSeenTimestamp) webrtc.lastSeenTimestamp = message.ts - # console.log('RTC ' + JSON.stringify(message)) webrtc.processIncomingRtcMessage(JSON.parse(message.msg), message.rid.replace(message.to, ''), message.rid) - - -# stream.on(Meteor.userId(), function(data) { -# webrtc.log('stream.on', Meteor.userId(), data) -# if (data.close == true) { -# webrtc.stop(false); -# } - -# if (!webrtc.pc) -# webrtc.start(false, data.from); -# -# if (data.sdp) { -# webrtc.pc.setRemoteDescription(new RTCSessionDescription(data.sdp)); -# } else { -# if( ["closed", "failed", "disconnected", "completed"].indexOf(webrtc.pc.iceConnectionState) === -1) { -# webrtc.pc.addIceCandidate(new RTCIceCandidate(data.candidate)); -# } -# } -#}); - - - RocketChat.callbacks.add 'renderRtcMessage', IncomingRtcMessageProcessor, RocketChat.callbacks.priority.LOW diff --git a/packages/rocketchat-webrtc/package.js b/packages/rocketchat-webrtc/package.js index b351ad7b2542..d494f1b56361 100644 --- a/packages/rocketchat-webrtc/package.js +++ b/packages/rocketchat-webrtc/package.js @@ -10,8 +10,7 @@ Package.onUse(function(api) { api.use([ 'coffeescript', - 'rocketchat:lib@0.0.1', - 'arunoda:streams@0.1.17' + 'rocketchat:lib@0.0.1' ]); api.addFiles('common.js'); diff --git a/server/stream/streamBroadcast.coffee b/server/stream/streamBroadcast.coffee index d1ad440cc901..1954d690fce1 100644 --- a/server/stream/streamBroadcast.coffee +++ b/server/stream/streamBroadcast.coffee @@ -49,6 +49,10 @@ Meteor.startup -> - startStreamBroadcast - 'webrtc.stream': webrtc.stream - 'typing': typingStream + if webrtc + startStreamBroadcast + 'webrtc.stream': webrtc.stream + 'typing': typingStream + else + startStreamBroadcast + 'typing': typingStream