pusher 1.3.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.github/stale.yml +26 -0
- data/.travis.yml +6 -5
- data/CHANGELOG.md +31 -1
- data/README.md +104 -119
- data/examples/presence_channels/presence_channels.rb +56 -0
- data/examples/presence_channels/public/presence_channels.html +28 -0
- data/lib/pusher.rb +1 -1
- data/lib/pusher/channel.rb +14 -2
- data/lib/pusher/client.rb +75 -5
- data/lib/pusher/request.rb +2 -0
- data/lib/pusher/version.rb +1 -1
- data/pusher.gemspec +12 -11
- data/spec/channel_spec.rb +25 -4
- data/spec/client_spec.rb +176 -5
- metadata +66 -50
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Mjk3MmUwODFhNDcxY2U1ZjVhZTlkMGUzYmZlMGE3NWY0ZGNkZGE3Mg==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 81a153328f0e5452bcdd87e9cd09339464a26679566f1d14f087fee9a29a69b2
|
4
|
+
data.tar.gz: f5e282e3a9f0d60d441da0ef023073cefa1d4ebd2ada5b7fcb82a258a53c402a
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZTBiNzUyODYzYWE4NjQxNDE5OWQ2ZjIxMTMwYzUwYTdhNjkyNTY0OWZmMDQ2
|
11
|
-
YTA4NWVmMTJmMmZhMmFiNGY0NTM4Mjg5YjhlMDRhM2FkNDcxYWE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZGZmNzQ0YmExMGMzZjlkY2U2Yzk5MzgyMWUwOTJhNzFmYjkxNTFkMGZmODNl
|
14
|
-
MmI4OGJlMmI0OGJiZjZhN2MwYzE3MDJiZWUzNzlhNzE1NDQ0OTQzODQxNTdj
|
15
|
-
ZGMwNGExNDljYTU4MjY1OTBjMWYzZTIzM2Q2YTdkMTY4OWI2Mzc=
|
6
|
+
metadata.gz: 87ed04a2e5bd63cfffd67798066dc9d014d119a00f7b6caad6c7d9a0d1a64c0a251c5f5b9706d883025532758e53f9a5d2f34579b555a206bb341182c624f58d
|
7
|
+
data.tar.gz: 7776a1f8477dc5d7d33efb0cb46edd3dfe0d77d7c40d691eb8cb525d71998216eb4fc7832b546fb7c43f7ec1bb1db5db32e169ed1d4d1c2cdd1291d89e9f8b73
|
data/.github/stale.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Configuration for probot-stale - https://github.com/probot/stale
|
2
|
+
|
3
|
+
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
4
|
+
daysUntilStale: 365
|
5
|
+
|
6
|
+
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
|
7
|
+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
8
|
+
daysUntilClose: 7
|
9
|
+
|
10
|
+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
|
11
|
+
onlyLabels: []
|
12
|
+
|
13
|
+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
14
|
+
exemptLabels:
|
15
|
+
- pinned
|
16
|
+
- security
|
17
|
+
|
18
|
+
# Set to true to ignore issues with an assignee (defaults to false)
|
19
|
+
exemptAssignees: true
|
20
|
+
|
21
|
+
# Comment to post when marking as stale. Set to `false` to disable
|
22
|
+
markComment: >
|
23
|
+
This issue has been automatically marked as stale because it has not had
|
24
|
+
recent activity. It will be closed if no further activity occurs. If you'd
|
25
|
+
like this issue to stay open please leave a comment indicating how this issue
|
26
|
+
is affecting you. Thankyou.
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,34 @@
|
|
1
|
+
1.4.2 / 2020-10-20
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Return `shared_secret` to support authenticating encrypted channels. Thanks
|
5
|
+
@Benjaminpjacobs
|
6
|
+
|
7
|
+
1.4.1 / 2020-10-05
|
8
|
+
==================
|
9
|
+
|
10
|
+
* Remove rbnacl from dependencies so we don't get errors when it isn't
|
11
|
+
required. Thanks @y-yagi!
|
12
|
+
|
13
|
+
1.4.0 / 2020-09-29
|
14
|
+
==================
|
15
|
+
|
16
|
+
* Support for end-to-end encryption.
|
17
|
+
|
18
|
+
1.3.3 / 2019-07-02
|
19
|
+
==================
|
20
|
+
|
21
|
+
* Rewording to clarify "Pusher Channels" or simply "Channels" product name.
|
22
|
+
|
23
|
+
1.3.2 / 2018-10-17
|
24
|
+
==================
|
25
|
+
|
26
|
+
* Return a specific error for "Request Entity Too Large" (body over 10KB).
|
27
|
+
* Add a `use_tls` option for SSL (defaults to false).
|
28
|
+
* Add a `from_url` client method (in addition to existing `from_env` option).
|
29
|
+
* Improved documentation and fixed typos.
|
30
|
+
* Add Ruby 2.4 to test matrix.
|
31
|
+
|
1
32
|
1.3.1 / 2017-03-15
|
2
33
|
==================
|
3
34
|
|
@@ -100,4 +131,3 @@ First release with a changelog !
|
|
100
131
|
|
101
132
|
* Bump httpclient to v2.4. See #62 (POODLE SSL)
|
102
133
|
* Fix limited channel count at README.md. Thanks @tricknotes
|
103
|
-
|
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
Pusher
|
2
|
-
==========
|
1
|
+
# Gem for Pusher Channels
|
3
2
|
|
4
|
-
[
|
3
|
+
This Gem provides a Ruby interface to [the Pusher HTTP API for Pusher Channels](https://pusher.com/docs/channels/library_auth_reference/rest-api).
|
5
4
|
|
6
|
-
|
5
|
+
[![Build Status](https://secure.travis-ci.org/pusher/pusher-http-ruby.svg?branch=master)](http://travis-ci.org/pusher/pusher-http-ruby) [![Gem Version](https://badge.fury.io/rb/pusher.svg)](https://badge.fury.io/rb/pusher)
|
7
6
|
|
8
|
-
|
7
|
+
## Installation and Configuration
|
8
|
+
|
9
|
+
Add `pusher` to your Gemfile, and then run `bundle install`
|
9
10
|
|
10
11
|
``` ruby
|
11
12
|
gem 'pusher'
|
@@ -17,68 +18,60 @@ or install via gem
|
|
17
18
|
gem install pusher
|
18
19
|
```
|
19
20
|
|
20
|
-
After registering at
|
21
|
+
After registering at [Pusher](https://dashboard.pusher.com/accounts/sign_up), configure your Channels app with the security credentials.
|
21
22
|
|
22
|
-
### Instantiating a Pusher client
|
23
|
+
### Instantiating a Pusher Channels client
|
23
24
|
|
24
|
-
Creating a new Pusher `client` can be done as follows.
|
25
|
+
Creating a new Pusher Channels `client` can be done as follows.
|
25
26
|
|
26
27
|
``` ruby
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
require 'pusher'
|
29
|
+
|
30
|
+
pusher = Pusher::Client.new(
|
31
|
+
app_id: 'your-app-id',
|
32
|
+
key: 'your-app-key',
|
33
|
+
secret: 'your-app-secret',
|
34
|
+
cluster: 'your-app-cluster',
|
35
|
+
use_tls: true
|
31
36
|
)
|
32
37
|
```
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
``` ruby
|
37
|
-
pusher_client = Pusher::Client.new(
|
38
|
-
app_id: 'your-pusher-app-id',
|
39
|
-
key: 'your-pusher-key',
|
40
|
-
secret: 'your-pusher-secret',
|
41
|
-
host: 'your-pusher-host'
|
42
|
-
)
|
43
|
-
```
|
39
|
+
The `cluster` value will set the `host` to `api-<cluster>.pusher.com`. The `use_tls` value is optional and defaults to `false`. It will set the `scheme` and `port`. Custom `scheme` and `port` values take precendence over `use_tls`.
|
44
40
|
|
45
|
-
If you
|
41
|
+
If you want to set a custom `host` value for your client then you can do so when instantiating a Pusher Channels client like so:
|
46
42
|
|
47
43
|
``` ruby
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
require 'pusher'
|
45
|
+
|
46
|
+
pusher = Pusher::Client.new(
|
47
|
+
app_id: 'your-app-id',
|
48
|
+
key: 'your-app-key',
|
49
|
+
secret: 'your-app-secret',
|
50
|
+
host: 'your-app-host'
|
53
51
|
)
|
54
52
|
```
|
55
53
|
|
56
|
-
|
54
|
+
If you pass both `host` and `cluster` options, the `host` will take precendence and `cluster` will be ignored.
|
57
55
|
|
58
56
|
Finally, if you have the configuration set in an `PUSHER_URL` environment
|
59
57
|
variable, you can use:
|
60
58
|
|
61
59
|
``` ruby
|
62
|
-
|
60
|
+
pusher = Pusher::Client.from_env
|
63
61
|
```
|
64
62
|
|
65
|
-
### Global
|
66
|
-
|
67
|
-
Configuring Pusher can also be done globally on the Pusher class.
|
68
|
-
|
69
|
-
``` ruby
|
70
|
-
Pusher.app_id = 'your-pusher-app-id'
|
71
|
-
Pusher.key = 'your-pusher-key'
|
72
|
-
Pusher.secret = 'your-pusher-secret'
|
73
|
-
```
|
63
|
+
### Global configuration
|
74
64
|
|
75
|
-
|
65
|
+
The library can also be configured globally on the `Pusher` class.
|
76
66
|
|
77
67
|
``` ruby
|
68
|
+
Pusher.app_id = 'your-app-id'
|
69
|
+
Pusher.key = 'your-app-key'
|
70
|
+
Pusher.secret = 'your-app-secret'
|
78
71
|
Pusher.cluster = 'your-app-cluster'
|
79
72
|
```
|
80
73
|
|
81
|
-
Global configuration will automatically be set from the `PUSHER_URL` environment variable if it exists. This should be in the form `http://KEY:SECRET@
|
74
|
+
Global configuration will automatically be set from the `PUSHER_URL` environment variable if it exists. This should be in the form `http://KEY:SECRET@HOST/apps/APP_ID`. On Heroku this environment variable will already be set.
|
82
75
|
|
83
76
|
If you need to make requests via a HTTP proxy then it can be configured
|
84
77
|
|
@@ -86,7 +79,8 @@ If you need to make requests via a HTTP proxy then it can be configured
|
|
86
79
|
Pusher.http_proxy = 'http://(user):(password)@(host):(port)'
|
87
80
|
```
|
88
81
|
|
89
|
-
By default API requests are made over HTTP. HTTPS can be used by setting
|
82
|
+
By default API requests are made over HTTP. HTTPS can be used by setting `encrypted` to `true`.
|
83
|
+
Issuing this command is going to reset `port` value if it was previously specified.
|
90
84
|
|
91
85
|
``` ruby
|
92
86
|
Pusher.encrypted = true
|
@@ -98,9 +92,9 @@ As of version 0.12, SSL certificates are verified when using the synchronous htt
|
|
98
92
|
Pusher.default_client.sync_http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
99
93
|
```
|
100
94
|
|
101
|
-
## Interacting with the
|
95
|
+
## Interacting with the Channels HTTP API
|
102
96
|
|
103
|
-
The
|
97
|
+
The `pusher` gem contains a number of helpers for interacting with the API. As a general rule, the library adheres to a set of conventions that we have aimed to make universal.
|
104
98
|
|
105
99
|
### Handling errors
|
106
100
|
|
@@ -108,7 +102,7 @@ Handle errors by rescuing `Pusher::Error` (all errors are descendants of this er
|
|
108
102
|
|
109
103
|
``` ruby
|
110
104
|
begin
|
111
|
-
|
105
|
+
pusher.trigger('a_channel', 'an_event', :some => 'data')
|
112
106
|
rescue Pusher::Error => e
|
113
107
|
# (Pusher::AuthenticationError, Pusher::HTTPError, or Pusher::Error)
|
114
108
|
end
|
@@ -127,14 +121,14 @@ Pusher.logger = Rails.logger
|
|
127
121
|
An event can be published to one or more channels (limited to 10) in one API call:
|
128
122
|
|
129
123
|
``` ruby
|
130
|
-
|
131
|
-
|
124
|
+
pusher.trigger('channel', 'event', foo: 'bar')
|
125
|
+
pusher.trigger(['channel_1', 'channel_2'], 'event_name', foo: 'bar')
|
132
126
|
```
|
133
127
|
|
134
|
-
An optional fourth argument may be used to send additional parameters to the API, for example to [exclude a single connection from receiving the event](
|
128
|
+
An optional fourth argument may be used to send additional parameters to the API, for example to [exclude a single connection from receiving the event](https://pusher.com/docs/channels/server_api/excluding-event-recipients).
|
135
129
|
|
136
130
|
``` ruby
|
137
|
-
|
131
|
+
pusher.trigger('channel', 'event', {foo: 'bar'}, {socket_id: '123.456'})
|
138
132
|
```
|
139
133
|
|
140
134
|
#### Batches
|
@@ -143,8 +137,8 @@ It's also possible to send multiple events with a single API call (max 10
|
|
143
137
|
events per call on multi-tenant clusters):
|
144
138
|
|
145
139
|
``` ruby
|
146
|
-
|
147
|
-
{channel: 'channel_1', name: 'event_name', data: { foo: 'bar' }}
|
140
|
+
pusher.trigger_batch([
|
141
|
+
{channel: 'channel_1', name: 'event_name', data: { foo: 'bar' }},
|
148
142
|
{channel: 'channel_1', name: 'event_name', data: { hello: 'world' }}
|
149
143
|
])
|
150
144
|
```
|
@@ -157,69 +151,69 @@ Most examples and documentation will refer to the following syntax for triggerin
|
|
157
151
|
Pusher['a_channel'].trigger('an_event', :some => 'data')
|
158
152
|
```
|
159
153
|
|
160
|
-
This will continue to work, but has been replaced by `
|
154
|
+
This will continue to work, but has been replaced by `pusher.trigger` which supports one or multiple channels.
|
161
155
|
|
162
|
-
###
|
156
|
+
### Getting information about the channels in your Pusher Channels app
|
163
157
|
|
164
|
-
This gem provides methods for accessing information from the [
|
158
|
+
This gem provides methods for accessing information from the [Channels HTTP API](https://pusher.com/docs/channels/library_auth_reference/rest-api). The documentation also shows an example of the responses from each of the API endpoints.
|
165
159
|
|
166
160
|
The following methods are provided by the gem.
|
167
161
|
|
168
|
-
- `
|
162
|
+
- `pusher.channel_info('channel_name', {info:"user_count,subscription_count"})` returns a hash describing the state of the channel([docs](https://pusher.com/docs/channels/library_auth_reference/rest-api#get-channels-fetch-info-for-multiple-channels-)).
|
169
163
|
|
170
|
-
- `
|
164
|
+
- `pusher.channel_users('presence-channel_name')` returns a list of all the users subscribed to the channel (only for Presence Channels) ([docs](https://pusher.com/docs/channels/library_auth_reference/rest-api#get-channels-fetch-info-for-multiple-channels-)).
|
171
165
|
|
172
|
-
- `
|
166
|
+
- `pusher.channels({filter_by_prefix: 'presence-', info: 'user_count'})` returns a hash of occupied channels (optionally filtered by prefix, f.i. `presence-`), and optionally attributes for these channels ([docs](https://pusher.com/docs/channels/library_auth_reference/rest-api#get-channels-fetch-info-for-multiple-channels-)).
|
173
167
|
|
174
168
|
### Asynchronous requests
|
175
169
|
|
176
170
|
There are two main reasons for using the `_async` methods:
|
177
171
|
|
178
|
-
* In a web application where the response from
|
172
|
+
* In a web application where the response from the Channels HTTP API is not used, but you'd like to avoid a blocking call in the request-response cycle
|
179
173
|
* Your application is running in an event loop and you need to avoid blocking the reactor
|
180
174
|
|
181
175
|
Asynchronous calls are supported either by using an event loop (eventmachine, preferred), or via a thread.
|
182
176
|
|
183
177
|
The following methods are available (in each case the calling interface matches the non-async version):
|
184
178
|
|
185
|
-
* `
|
186
|
-
* `
|
187
|
-
* `
|
179
|
+
* `pusher.get_async`
|
180
|
+
* `pusher.post_async`
|
181
|
+
* `pusher.trigger_async`
|
188
182
|
|
189
|
-
It is of course also possible to make calls to
|
183
|
+
It is of course also possible to make calls to the Channels HTTP API via a job queue. This approach is recommended if you're sending a large number of events.
|
190
184
|
|
191
|
-
#### With
|
185
|
+
#### With EventMachine
|
192
186
|
|
193
187
|
* Add the `em-http-request` gem to your Gemfile (it's not a gem dependency).
|
194
|
-
* Run the
|
188
|
+
* Run the EventMachine reactor (either using `EM.run` or by running inside an evented server such as Thin).
|
195
189
|
|
196
190
|
The `_async` methods return an `EM::Deferrable` which you can bind callbacks to:
|
197
191
|
|
198
192
|
``` ruby
|
199
|
-
|
193
|
+
pusher.get_async("/channels").callback { |response|
|
200
194
|
# use reponse[:channels]
|
201
195
|
}.errback { |error|
|
202
196
|
# error is an instance of Pusher::Error
|
203
197
|
}
|
204
198
|
```
|
205
199
|
|
206
|
-
A HTTP error or an error response from
|
200
|
+
A HTTP error or an error response from Channels will cause the errback to be called with an appropriate error object.
|
207
201
|
|
208
|
-
#### Without
|
202
|
+
#### Without EventMachine
|
209
203
|
|
210
|
-
If the
|
204
|
+
If the EventMachine reactor is not running, async requests will be made using threads (managed by the httpclient gem).
|
211
205
|
|
212
206
|
An `HTTPClient::Connection` object is returned immediately which can be [interrogated](http://rubydoc.info/gems/httpclient/HTTPClient/Connection) to discover the status of the request. The usual response checking and processing is not done when the request completes, and frankly this method is most useful when you're not interested in waiting for the response.
|
213
207
|
|
214
208
|
|
215
209
|
## Authenticating subscription requests
|
216
210
|
|
217
|
-
It's possible to use the gem to authenticate subscription requests to private or presence channels. The `authenticate` method is available on a channel object for this purpose and returns a JSON object that can be returned to the client that made the request. More information on this authentication scheme can be found in the docs on <
|
211
|
+
It's possible to use the gem to authenticate subscription requests to private or presence channels. The `authenticate` method is available on a channel object for this purpose and returns a JSON object that can be returned to the client that made the request. More information on this authentication scheme can be found in the docs on <https://pusher.com/docs/channels/server_api/authenticating-users>
|
218
212
|
|
219
213
|
### Private channels
|
220
214
|
|
221
215
|
``` ruby
|
222
|
-
|
216
|
+
pusher.authenticate('private-my_channel', params[:socket_id])
|
223
217
|
```
|
224
218
|
|
225
219
|
### Presence channels
|
@@ -227,7 +221,7 @@ Pusher.authenticate('private-my_channel', params[:socket_id])
|
|
227
221
|
These work in a very similar way, but require a unique identifier for the user being authenticated, and optionally some attributes that are provided to clients via presence events:
|
228
222
|
|
229
223
|
``` ruby
|
230
|
-
|
224
|
+
pusher.authenticate('presence-my_channel', params[:socket_id],
|
231
225
|
user_id: 'user_id',
|
232
226
|
user_info: {} # optional
|
233
227
|
)
|
@@ -238,7 +232,7 @@ Pusher.authenticate('presence-my_channel', params[:socket_id],
|
|
238
232
|
A WebHook object may be created to validate received WebHooks against your app credentials, and to extract events. It should be created with the `Rack::Request` object (available as `request` in Rails controllers or Sinatra handlers for example).
|
239
233
|
|
240
234
|
``` ruby
|
241
|
-
webhook =
|
235
|
+
webhook = pusher.webhook(request)
|
242
236
|
if webhook.valid?
|
243
237
|
webhook.events.each do |event|
|
244
238
|
case event["name"]
|
@@ -254,62 +248,53 @@ else
|
|
254
248
|
end
|
255
249
|
```
|
256
250
|
|
257
|
-
|
251
|
+
### End-to-end encryption
|
258
252
|
|
259
|
-
|
253
|
+
This library supports [end-to-end encrypted channels](https://pusher.com/docs/channels/using_channels/encrypted-channels). This means that only you and your connected clients will be able to read your messages. Pusher cannot decrypt them. You can enable this feature by following these steps:
|
260
254
|
|
261
|
-
|
255
|
+
1. Add the `rbnacl` gem to your Gemfile (it's not a gem dependency).
|
262
256
|
|
263
|
-
|
257
|
+
2. Install [Libsodium](https://github.com/jedisct1/libsodium), which we rely on to do the heavy lifting. [Follow the installation instructions for your platform.](https://github.com/RubyCrypto/rbnacl/wiki/Installing-libsodium)
|
264
258
|
|
265
|
-
|
259
|
+
3. Encrypted channel subscriptions must be authenticated in the exact same way as private channels. You should therefore [create an authentication endpoint on your server](https://pusher.com/docs/authenticating_users).
|
266
260
|
|
267
|
-
|
268
|
-
- `data`: The content of the notification represented by a Hash. You must supply either the `gcm` or `apns` key. For a detailed list of the acceptable keys, take a look at the [iOS](https://pusher.com/docs/push_notifications/ios/server) and [Android](https://pusher.com/docs/push_notifications/android/server) docs.
|
261
|
+
4. Next, generate your 32 byte master encryption key, encode it as base64 and pass it to the Pusher constructor.
|
269
262
|
|
270
|
-
|
263
|
+
This is secret and you should never share this with anyone.
|
264
|
+
Not even Pusher.
|
271
265
|
|
272
|
-
```
|
273
|
-
|
274
|
-
|
275
|
-
aps: {
|
276
|
-
alert: {
|
277
|
-
body: 'tada'
|
278
|
-
}
|
279
|
-
}
|
280
|
-
}
|
281
|
-
}
|
266
|
+
```bash
|
267
|
+
openssl rand -base64 32
|
268
|
+
```
|
282
269
|
|
283
|
-
|
284
|
-
|
270
|
+
```rb
|
271
|
+
pusher = new Pusher::Client.new({
|
272
|
+
app_id: 'your-app-id',
|
273
|
+
key: 'your-app-key',
|
274
|
+
secret: 'your-app-secret',
|
275
|
+
cluster: 'your-app-cluster',
|
276
|
+
use_tls: true
|
277
|
+
encryption_master_key_base64: '<KEY GENERATED BY PREVIOUS COMMAND>',
|
278
|
+
});
|
279
|
+
```
|
285
280
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
```
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
}
|
301
|
-
}
|
302
|
-
},
|
303
|
-
gcm: {
|
304
|
-
notification: {
|
305
|
-
title: "hello",
|
306
|
-
icon: "icon"
|
307
|
-
}
|
308
|
-
},
|
309
|
-
webhook_url: "http://yolo.com",
|
310
|
-
webhook_level: "INFO"
|
311
|
-
}
|
281
|
+
5. Channels where you wish to use end-to-end encryption should be prefixed with `private-encrypted-`.
|
282
|
+
|
283
|
+
6. Subscribe to these channels in your client, and you're done! You can verify it is working by checking out the debug console on the [https://dashboard.pusher.com/](dashboard) and seeing the scrambled ciphertext.
|
284
|
+
|
285
|
+
**Important note: This will __not__ encrypt messages on channels that are not prefixed by `private-encrypted-`.**
|
286
|
+
|
287
|
+
**Limitation**: you cannot trigger a single event on multiple channels in a call to `trigger`, e.g.
|
288
|
+
|
289
|
+
```rb
|
290
|
+
pusher.trigger(
|
291
|
+
['channel-1', 'private-encrypted-channel-2'],
|
292
|
+
'test_event',
|
293
|
+
{ message: 'hello world' },
|
294
|
+
)
|
312
295
|
```
|
313
296
|
|
314
|
-
|
297
|
+
Rationale: the methods in this library map directly to individual Channels HTTP API requests. If we allowed triggering a single event on multiple channels (some encrypted, some unencrypted), then it would require two API requests: one where the event is encrypted to the encrypted channels, and one where the event is unencrypted for unencrypted channels.
|
315
298
|
|
299
|
+
## Supported Ruby versions
|
300
|
+
2.4+
|