You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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](http://pusher.com/docs/publisher_api_guide/publisher_excluding_recipients).
This will continue to work, but has been replaced by `Pusher.trigger` which supports one or multiple channels.
152
+
This will continue to work, but has been replaced by `channels_client.trigger` which supports one or multiple channels.
152
153
153
-
### Using the Pusher REST API
154
+
### Getting information about the channels in your Pusher Channels app
154
155
155
-
This gem provides methods for accessing information from the [Pusher REST API](https://pusher.com/docs/rest_api). The documentation also shows an example of the responses from each of the API endpionts.
156
+
This gem provides methods for accessing information from the [Pusher HTTP API](https://pusher.com/docs/rest_api). The documentation also shows an example of the responses from each of the API endpionts.
156
157
157
158
The following methods are provided by the gem.
158
159
159
-
-`Pusher.channel_info('channel_name')` returns information about that channel.
160
+
-`channels_client.channel_info('channel_name')` returns information about that channel.
160
161
161
-
-`Pusher.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
162
+
-`channels_client.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
162
163
163
-
-`Pusher.channels` returns information about all the channels in your Pusher application.
164
+
-`channels_client.channels` returns information about all the channels in your Pusher application.
164
165
165
166
### Asynchronous requests
166
167
167
168
There are two main reasons for using the `_async` methods:
168
169
169
-
* In a web application where the response from Pusher is not used, but you'd like to avoid a blocking call in the request-response cycle
170
+
* In a web application where the response from the Pusher Channels HTTP API is not used, but you'd like to avoid a blocking call in the request-response cycle
170
171
* Your application is running in an event loop and you need to avoid blocking the reactor
171
172
172
173
Asynchronous calls are supported either by using an event loop (eventmachine, preferred), or via a thread.
173
174
174
175
The following methods are available (in each case the calling interface matches the non-async version):
175
176
176
-
*`Pusher.get_async`
177
-
*`Pusher.post_async`
178
-
*`Pusher.trigger_async`
177
+
*`channels_client.get_async`
178
+
*`channels_client.post_async`
179
+
*`channels_client.trigger_async`
179
180
180
-
It is of course also possible to make calls to pusher via a job queue. This approach is recommended if you're sending a large number of events to pusher.
181
+
It is of course also possible to make calls to the Pusher Channels HTTP API via a job queue. This approach is recommended if you're sending a large number of events.
181
182
182
-
#### With eventmachine
183
+
#### With EventMachine
183
184
184
185
* Add the `em-http-request` gem to your Gemfile (it's not a gem dependency).
185
-
* Run the eventmachine reactor (either using `EM.run` or by running inside an evented server such as Thin).
186
+
* Run the EventMachine reactor (either using `EM.run` or by running inside an evented server such as Thin).
186
187
187
188
The `_async` methods return an `EM::Deferrable` which you can bind callbacks to:
A HTTP error or an error response from pusher will cause the errback to be called with an appropriate error object.
198
199
199
-
#### Without eventmachine
200
+
#### Without EventMachine
200
201
201
-
If the eventmachine reactor is not running, async requests will be made using threads (managed by the httpclient gem).
202
+
If the EventMachine reactor is not running, async requests will be made using threads (managed by the httpclient gem).
202
203
203
204
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.
204
205
@@ -210,15 +211,15 @@ It's possible to use the gem to authenticate subscription requests to private or
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:
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).
0 commit comments