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.
153
+
This will continue to work, but has been replaced by `channels_client.trigger` which supports one or multiple channels.
153
154
154
-
###Using the Pusher REST API
155
+
### Getting information about the channels in your Pusher Channels app
155
156
156
-
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 endpoints.
157
+
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 endpoints.
157
158
158
159
The following methods are provided by the gem.
159
160
160
-
-`Pusher.channel_info('channel_name')` returns information about that channel.
161
+
-`channels_client.channel_info('channel_name')` returns information about that channel.
161
162
162
-
-`Pusher.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
163
+
-`channels_client.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
163
164
164
-
-`Pusher.channels` returns information about all the channels in your Pusher application.
165
+
-`channels_client.channels` returns information about all the channels in your Pusher application.
165
166
166
167
### Asynchronous requests
167
168
168
169
There are two main reasons for using the `_async` methods:
169
170
170
-
* 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
171
+
* 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
171
172
* Your application is running in an event loop and you need to avoid blocking the reactor
172
173
173
174
Asynchronous calls are supported either by using an event loop (eventmachine, preferred), or via a thread.
174
175
175
176
The following methods are available (in each case the calling interface matches the non-async version):
176
177
177
-
*`Pusher.get_async`
178
-
*`Pusher.post_async`
179
-
*`Pusher.trigger_async`
178
+
*`channels_client.get_async`
179
+
*`channels_client.post_async`
180
+
*`channels_client.trigger_async`
180
181
181
-
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.
182
+
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.
182
183
183
-
#### With eventmachine
184
+
#### With EventMachine
184
185
185
186
* Add the `em-http-request` gem to your Gemfile (it's not a gem dependency).
186
-
* Run the eventmachine reactor (either using `EM.run` or by running inside an evented server such as Thin).
187
+
* Run the EventMachine reactor (either using `EM.run` or by running inside an evented server such as Thin).
187
188
188
189
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.
199
200
200
-
#### Without eventmachine
201
+
#### Without EventMachine
201
202
202
-
If the eventmachine reactor is not running, async requests will be made using threads (managed by the httpclient gem).
203
+
If the EventMachine reactor is not running, async requests will be made using threads (managed by the httpclient gem).
203
204
204
205
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.
205
206
@@ -211,15 +212,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