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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 643e6f36529bf140d6da5ebf72f924c7700b9bea
4
- data.tar.gz: 498a7b8496a5c3831aa642cb3d42012d9c2904cc
3
+ metadata.gz: 0e42286f0f578e7c50fbc02e8718dffc5f137813
4
+ data.tar.gz: 1bab5500d6106da4d5ab92f731368edba4e05bb5
5
5
  SHA512:
6
- metadata.gz: 6e02dc861006c7434f994335bfdeed68d1a22843995a7fad893006e15ab5350e25e75aceeb42633a4a0c9e02ab5f31b21c0f67722fe3d36947c29f4b2e3b70fe
7
- data.tar.gz: b03c263bde72518cef778a4d2ea4905b50efed172d01ce3c36ead625546eb2db9bf90185a82e60bc12c0485695783cf08dfadb2d25dc06684c25472e0b798fc7
6
+ metadata.gz: b7c9fe5c45454e28ced58826f3085ad22e7786efbd6c91c78cfd5f84b121173aa07bed10f307b9a34902bb5342031e7a53d70d866ce3e93466ee4f4977487c62
7
+ data.tar.gz: e41bf81bfcdb494dbeb121f0b4e4bf79ba17a3984c9fa7af256a87e50ffd043d036d31702b342a340f9fc45c245ba4f11ef63f0ef450f45e17016ea04c37fb3a
@@ -6,6 +6,7 @@ module WebrtcRails
6
6
  def add_gems
7
7
  gem 'daemons-rails'
8
8
  gem 'em-websocket'
9
+ gem 'em-hiredis'
9
10
  end
10
11
 
11
12
  def injection
@@ -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
@@ -1 +1,2 @@
1
+ require 'webrtc_rails/server_message'
1
2
  require 'webrtc_rails/version'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module WebrtcRails
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
data/webrtc-rails.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'em-websocket'
22
+ spec.add_dependency 'redis'
22
23
  spec.add_dependency 'daemons-rails'
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.10"
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.5
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-20 00:00:00.000000000 Z
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