janus_gateway 0.0.14 → 0.0.15

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: a1c223b56a2536ca40478bedafffd54a112a5241
4
- data.tar.gz: 237bfe5ea272325d3adf04154546d89ec7b82c64
3
+ metadata.gz: 6ea317eec80f95f86608e0dfbefd20daf539ca93
4
+ data.tar.gz: 1f71d212cee640fba2e50565c7101e0f49d935fa
5
5
  SHA512:
6
- metadata.gz: fdf055d236fd6f6729c2df0ea3d57b3d10c05e87a32ee56127dbf8398542ffd34af38d3b53afcef731aee8cf7096beb3be22c3b40e560c8e2c4ebf42c02839a6
7
- data.tar.gz: 943df4c7904262727e92fab0a3d2ad38f3e4be7d202c20d8d049c8d86ac9ab918c18a1f90be898adc449c1ef725a72ca1bc6dd216c5652326cdd4c481c7449ab
6
+ metadata.gz: f02c94833d104e2fdc74b4d108e7b34883865d222df26d46810ba255f994f7272f6dae43ec4234db2d3d5d6f11db825ca6ebc1540d577d7f02b0f256c4b8c6e9
7
+ data.tar.gz: 3d9245725745520b7e400e4e837ebbe4d81578c6679de4769231c9a3867dff17625745ad5f4e014409f75d24a8229c147646eea9a4b8c2e111ec51d9fd50b3c3
data/README.md CHANGED
@@ -28,7 +28,20 @@ ws = JanusGateway::Transport::WebSocket.new('ws://localhost:8188/janus')
28
28
  client = JanusGateway::Client.new(ws)
29
29
  ```
30
30
 
31
- This client is used by all other classes connecting to api no matter if it's Resource or helper class like Agent.
31
+ The client's `connect` method should be called in an [EventMachine](https://github.com/eventmachine/eventmachine) context, for events to be emitted etc.
32
+ You can call the `run` method to start an EventMachine (which will block the execution of the program):
33
+ ```ruby
34
+ ws = JanusGateway::Transport::WebSocket.new('ws://localhost:8188/janus')
35
+ client = JanusGateway::Client.new(ws)
36
+
37
+ client.on(:open) do
38
+ # We can start sending commands to the server now
39
+ end
40
+
41
+ client.run
42
+ ```
43
+
44
+ Refer to the [Examples](#examples) section for a complete example of connecting to a server.
32
45
 
33
46
  ### Transports
34
47
  Client allows to use multiple, supported by Janus transportation layers. Currently the `WebSocket` transport is implemented and is the default.
@@ -132,6 +145,26 @@ Plugin resource supports `events` and `chaining` in the same way like `Janus` re
132
145
  ##### List
133
146
  Endpoint allows to retrieve the list of current audio rooms.
134
147
 
148
+ Examples
149
+ --------
150
+
151
+ Connect to the server using the WebSocket transport and create a session:
152
+ ```ruby
153
+ ws = JanusGateway::Transport::WebSocket.new('ws://localhost:8188/janus')
154
+ client = JanusGateway::Client.new(ws)
155
+ client.on(:open) { puts 'client connected' }
156
+ client.on(:close) { puts 'client disconnected' }
157
+
158
+ client.on(:open) do
159
+ session = JanusGateway::Resource::Session.new(client)
160
+ session.on(:create) { puts 'session created' }
161
+ session.on(:destroy) { puts 'session destroyed' }
162
+ session.create
163
+ end
164
+
165
+ client.run
166
+ ```
167
+
135
168
  Development
136
169
  -----------
137
170
 
@@ -64,6 +64,7 @@ module JanusGateway
64
64
 
65
65
  # @param [Hash] data
66
66
  def send(data)
67
+ raise 'WebSocket transport not connected' unless connected?
67
68
  client.send(JSON.generate(data))
68
69
  end
69
70
 
@@ -1,3 +1,3 @@
1
1
  module JanusGateway
2
- VERSION = '0.0.14'.freeze
2
+ VERSION = '0.0.15'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: janus_gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-10-06 00:00:00.000000000 Z
14
+ date: 2016-12-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faye-websocket
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  requirements: []
188
188
  rubyforge_project:
189
- rubygems_version: 2.5.1
189
+ rubygems_version: 2.5.2
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: janus-gateway client