webrtc-rails 0.1.5 → 0.2.0
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 +1 -0
- data/lib/generators/webrtc_rails/templates/main.js.coffee +3 -0
- data/lib/generators/webrtc_rails/templates/webrtc.rb +18 -0
- data/lib/webrtc-rails.rb +1 -0
- data/lib/webrtc_rails/server_message.rb +17 -0
- data/lib/webrtc_rails/version.rb +1 -1
- data/webrtc-rails.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e42286f0f578e7c50fbc02e8718dffc5f137813
|
4
|
+
data.tar.gz: 1bab5500d6106da4d5ab92f731368edba4e05bb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7c9fe5c45454e28ced58826f3085ad22e7786efbd6c91c78cfd5f84b121173aa07bed10f307b9a34902bb5342031e7a53d70d866ce3e93466ee4f4977487c62
|
7
|
+
data.tar.gz: e41bf81bfcdb494dbeb121f0b4e4bf79ba17a3984c9fa7af256a87e50ffd043d036d31702b342a340f9fc45c245ba4f11ef63f0ef450f45e17016ea04c37fb3a
|
@@ -13,6 +13,7 @@ class @WebRTC
|
|
13
13
|
onWebRTCReconnected: ->
|
14
14
|
onWebRTCHangedUp: ->
|
15
15
|
onWebRTCConnectFailed: (reason) ->
|
16
|
+
onServerMessage: (message) ->
|
16
17
|
|
17
18
|
constructor: (url, userToken, localOutput, remoteOutput) ->
|
18
19
|
@localOutput = if localOutput? then (localOutput[0] || localOutput) else null
|
@@ -138,6 +139,8 @@ class @WebRTC
|
|
138
139
|
when 'candidate'
|
139
140
|
if @_peerStarted
|
140
141
|
@_onCandidate(event)
|
142
|
+
when 'serverMessage'
|
143
|
+
@onServerMessage(event['message'])
|
141
144
|
|
142
145
|
_addNetworkEventListener: ->
|
143
146
|
window.addEventListener('offline', (event) =>
|
@@ -11,6 +11,24 @@ require File.join(root, "config", "environment")
|
|
11
11
|
@websockets = {}
|
12
12
|
|
13
13
|
EM.run do
|
14
|
+
redis = EM::Hiredis.connect
|
15
|
+
pubsub = redis.pubsub
|
16
|
+
pubsub.subscribe('webrtc-rails')
|
17
|
+
pubsub.on(:message) do |channel, message|
|
18
|
+
data = JSON.parse(message, {symbolize_names: true})
|
19
|
+
user_id = data[:user_id].to_s
|
20
|
+
message = data[:message]
|
21
|
+
if @websockets.key?(user_id)
|
22
|
+
for ws in @websockets[user_id]
|
23
|
+
send_data = {
|
24
|
+
type: 'serverMessage',
|
25
|
+
message: message
|
26
|
+
}
|
27
|
+
ws.send JSON.generate(send_data)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
14
32
|
EM::WebSocket.run(host: 'localhost', port: 3001) do |websocket|
|
15
33
|
my_user_id = nil
|
16
34
|
|
data/lib/webrtc-rails.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'redis'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module WebrtcRails
|
5
|
+
module ServerMessage
|
6
|
+
def send(user_id, message)
|
7
|
+
data = {
|
8
|
+
user_id: user_id,
|
9
|
+
message: message,
|
10
|
+
}
|
11
|
+
redis = Redis.new
|
12
|
+
redis.publish('webrtc-rails', JSON.generate(data))
|
13
|
+
end
|
14
|
+
|
15
|
+
module_function :send
|
16
|
+
end
|
17
|
+
end
|
data/lib/webrtc_rails/version.rb
CHANGED
data/webrtc-rails.gemspec
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.
|
4
|
+
version: 0.2.0
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-websocket
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: redis
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: daemons-rails
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,7 @@ files:
|
|
108
122
|
- lib/generators/webrtc_rails/templates/webrtc_controller.rb
|
109
123
|
- lib/generators/webrtc_rails/templates/webrtc_ctl
|
110
124
|
- lib/webrtc-rails.rb
|
125
|
+
- lib/webrtc_rails/server_message.rb
|
111
126
|
- lib/webrtc_rails/version.rb
|
112
127
|
- webrtc-rails.gemspec
|
113
128
|
homepage: https://github.com/malt03/webrtc-rails
|