webrtc-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/webrtc_rails/install/install_generator.rb +3 -3
- data/lib/generators/webrtc_rails/{install/templates → templates}/main.js.coffee +29 -3
- data/lib/generators/webrtc_rails/{install/templates → templates}/webrtc_controller.rb +0 -0
- data/lib/generators/webrtc_rails/update/USAGE +8 -0
- data/lib/generators/webrtc_rails/update/install_generator.rb +28 -0
- data/lib/generators/webrtc_rails/update/update_generator.rb +17 -0
- data/lib/webrtc_rails/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7b6982702ac1ff5a8a1febe6aaea3b29113726b
|
4
|
+
data.tar.gz: 4fda457eecd9ba82e3b4fc299803f91045399cd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31a1272ad27b944205ee02a68c4539d1e1d85801fdfcdd857070a25bdcaa9cb92748263c21e206bd6128fb5c5a84657f599d5eb73dcc168568344a1fa5648fec
|
7
|
+
data.tar.gz: 65c89139363d3dbd212100e831685a4a960c7ac0cc610884dadb6ef032746ec969d925c10db48ee8e64f1f30e3ce8f8548618228ce4e3ebaa7ae9721eaeae3c9
|
@@ -3,15 +3,15 @@ require 'rails'
|
|
3
3
|
module WebrtcRails
|
4
4
|
module Generators
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path("
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
7
7
|
|
8
8
|
def create_events_initializer_file
|
9
9
|
js_path = File.join('app', 'assets', 'javascripts')
|
10
10
|
template 'main.js.coffee', File.join(js_path, 'webrtc_rails', 'main.js.coffee')
|
11
11
|
append_to_file File.join(js_path, 'application.js') do
|
12
12
|
out = ''
|
13
|
-
out <<
|
14
|
-
out << "\n"
|
13
|
+
out << "\n\n// append by webrtc_rails\n"
|
14
|
+
out << "//= require webrtc_rails/main\n\n"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -1,5 +1,11 @@
|
|
1
1
|
class @WebRTC
|
2
|
+
onConnected: ->
|
3
|
+
onHangedUp: ->
|
4
|
+
onReconnectingStarted: ->
|
5
|
+
|
2
6
|
constructor: (userID, @localOutput, @remoteOutput) ->
|
7
|
+
@localOutput = @localOutput[0] || @localOutput
|
8
|
+
@remoteOutput = @remoteOutput[0] || @remoteOutput
|
3
9
|
@_startOutput(@localOutput.tagName.toUpperCase() == 'VIDEO')
|
4
10
|
@wsRails = new WebSocketRails(location.host + "/websocket?webrtc=true&user_identifier=" + userID)
|
5
11
|
@wsRails.bind("webrtc"
|
@@ -8,6 +14,13 @@ class @WebRTC
|
|
8
14
|
switch event['type']
|
9
15
|
when 'call'
|
10
16
|
@remoteUserID = event['remoteUserID']
|
17
|
+
when 'hangUp'
|
18
|
+
@onHangedUp()
|
19
|
+
@_hangedUp = true
|
20
|
+
@_sendMessage(JSON.stringify(type: 'hangUpAnswer'))
|
21
|
+
@_stop()
|
22
|
+
when 'hangUpAnswer'
|
23
|
+
@_stop()
|
11
24
|
when 'offer'
|
12
25
|
@_onOffer(event)
|
13
26
|
when 'answer'
|
@@ -44,10 +57,13 @@ class @WebRTC
|
|
44
57
|
track.enabled = enabled
|
45
58
|
|
46
59
|
hangUp: ->
|
47
|
-
@
|
60
|
+
@onHangedUp()
|
61
|
+
@_sendMessage(JSON.stringify(type: 'hangUp'))
|
62
|
+
@_hangedUp = true
|
48
63
|
|
49
64
|
# private
|
50
65
|
|
66
|
+
_hangedUp: true
|
51
67
|
_localStream: null
|
52
68
|
_peerConnection: null
|
53
69
|
_peerStarted: false
|
@@ -58,7 +74,7 @@ class @WebRTC
|
|
58
74
|
_sendMessage: (message) ->
|
59
75
|
$.ajax(
|
60
76
|
type: 'POST'
|
61
|
-
url: 'webrtc'
|
77
|
+
url: '/webrtc'
|
62
78
|
data:
|
63
79
|
user_id: @remoteUserID
|
64
80
|
message: message
|
@@ -125,6 +141,15 @@ class @WebRTC
|
|
125
141
|
candidate: event.candidate.candidate
|
126
142
|
)
|
127
143
|
|
144
|
+
peer.oniceconnectionstatechange = (event) =>
|
145
|
+
switch peer.iceConnectionState
|
146
|
+
when 'disconnected'
|
147
|
+
@onReconnectingStarted()
|
148
|
+
when 'connected', 'completed'
|
149
|
+
if @_hangedUp
|
150
|
+
@onConnected()
|
151
|
+
@_hangedUp = false
|
152
|
+
|
128
153
|
peer.addStream(@_localStream)
|
129
154
|
peer.addEventListener('addstream', onRemoteStreamAdded, false)
|
130
155
|
peer.addEventListener('removestream', onRemoteStreamRemoved, false)
|
@@ -153,7 +178,7 @@ class @WebRTC
|
|
153
178
|
return
|
154
179
|
@_peerConnection.createAnswer(
|
155
180
|
(sessionDescription) =>
|
156
|
-
@_peerConnection.setLocalDescription
|
181
|
+
@_peerConnection.setLocalDescription(sessionDescription)
|
157
182
|
@_sendSDP(sessionDescription)
|
158
183
|
->
|
159
184
|
console.log('Create Answer failed')
|
@@ -167,6 +192,7 @@ class @WebRTC
|
|
167
192
|
@_peerConnection.setRemoteDescription(new RTCSessionDescription(event))
|
168
193
|
|
169
194
|
_stop: ->
|
195
|
+
@_peerConnection.removeStream(@_peerConnection.getRemoteStreams()[0])
|
170
196
|
@_peerConnection.close()
|
171
197
|
@_peerConnection = null
|
172
198
|
@_peerStarted = false
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module WebrtcRails
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
7
|
+
|
8
|
+
def create_events_initializer_file
|
9
|
+
js_path = File.join('app', 'assets', 'javascripts')
|
10
|
+
template 'main.js.coffee', File.join(js_path, 'webrtc_rails', 'main.js.coffee')
|
11
|
+
append_to_file File.join(js_path, 'application.js') do
|
12
|
+
out = ''
|
13
|
+
out << "\n\n// append by webrtc_rails\n"
|
14
|
+
out << "//= require webrtc_rails/main\n\n"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_webrtc_controller
|
19
|
+
controller_path = File.join('app', 'controllers')
|
20
|
+
template 'webrtc_controller.rb', File.join(controller_path, 'webrtc_controller.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_route
|
24
|
+
route "post '/webrtc', :to => 'webrtc#send_message'"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module WebrtcRails
|
4
|
+
module Generators
|
5
|
+
class UpdateGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
7
|
+
|
8
|
+
def update_all_files
|
9
|
+
js_path = File.join('app', 'assets', 'javascripts')
|
10
|
+
template 'main.js.coffee', File.join(js_path, 'webrtc_rails', 'main.js.coffee')
|
11
|
+
controller_path = File.join('app', 'controllers')
|
12
|
+
template 'webrtc_controller.rb', File.join(controller_path, 'webrtc_controller.rb')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/webrtc_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webrtc-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koji Murata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket-rails
|
@@ -85,8 +85,11 @@ files:
|
|
85
85
|
- bin/setup
|
86
86
|
- lib/generators/webrtc_rails/install/USAGE
|
87
87
|
- lib/generators/webrtc_rails/install/install_generator.rb
|
88
|
-
- lib/generators/webrtc_rails/
|
89
|
-
- lib/generators/webrtc_rails/
|
88
|
+
- lib/generators/webrtc_rails/templates/main.js.coffee
|
89
|
+
- lib/generators/webrtc_rails/templates/webrtc_controller.rb
|
90
|
+
- lib/generators/webrtc_rails/update/USAGE
|
91
|
+
- lib/generators/webrtc_rails/update/install_generator.rb
|
92
|
+
- lib/generators/webrtc_rails/update/update_generator.rb
|
90
93
|
- lib/webrtc-rails.rb
|
91
94
|
- lib/webrtc_rails/version.rb
|
92
95
|
- webrtc-rails.gemspec
|