Skip to content

Commit a6d255d

Browse files
author
Anya Zenkina
authored
channels_client -> pusher (#150)
1 parent 56ccda2 commit a6d255d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Creating a new Pusher Channels `client` can be done as follows.
2727
``` ruby
2828
require 'pusher'
2929

30-
channels_client = Pusher::Client.new(
30+
pusher = Pusher::Client.new(
3131
app_id: 'your-app-id',
3232
key: 'your-app-key',
3333
secret: 'your-app-secret',
@@ -43,7 +43,7 @@ If you want to set a custom `host` value for your client then you can do so when
4343
``` ruby
4444
require 'pusher'
4545

46-
channels_client = Pusher::Client.new(
46+
pusher = Pusher::Client.new(
4747
app_id: 'your-app-id',
4848
key: 'your-app-key',
4949
secret: 'your-app-secret',
@@ -57,7 +57,7 @@ Finally, if you have the configuration set in an `PUSHER_URL` environment
5757
variable, you can use:
5858

5959
``` ruby
60-
channels_client = Pusher::Client.from_env
60+
pusher = Pusher::Client.from_env
6161
```
6262

6363
### Global configuration
@@ -102,7 +102,7 @@ Handle errors by rescuing `Pusher::Error` (all errors are descendants of this er
102102

103103
``` ruby
104104
begin
105-
channels_client.trigger('a_channel', 'an_event', :some => 'data')
105+
pusher.trigger('a_channel', 'an_event', :some => 'data')
106106
rescue Pusher::Error => e
107107
# (Pusher::AuthenticationError, Pusher::HTTPError, or Pusher::Error)
108108
end
@@ -121,14 +121,14 @@ Pusher.logger = Rails.logger
121121
An event can be published to one or more channels (limited to 10) in one API call:
122122

123123
``` ruby
124-
channels_client.trigger('channel', 'event', foo: 'bar')
125-
channels_client.trigger(['channel_1', 'channel_2'], 'event_name', foo: 'bar')
124+
pusher.trigger('channel', 'event', foo: 'bar')
125+
pusher.trigger(['channel_1', 'channel_2'], 'event_name', foo: 'bar')
126126
```
127127

128128
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).
129129

130130
``` ruby
131-
channels_client.trigger('channel', 'event', {foo: 'bar'}, {socket_id: '123.456'})
131+
pusher.trigger('channel', 'event', {foo: 'bar'}, {socket_id: '123.456'})
132132
```
133133

134134
#### Batches
@@ -137,7 +137,7 @@ It's also possible to send multiple events with a single API call (max 10
137137
events per call on multi-tenant clusters):
138138

139139
``` ruby
140-
channels_client.trigger_batch([
140+
pusher.trigger_batch([
141141
{channel: 'channel_1', name: 'event_name', data: { foo: 'bar' }},
142142
{channel: 'channel_1', name: 'event_name', data: { hello: 'world' }}
143143
])
@@ -151,19 +151,19 @@ Most examples and documentation will refer to the following syntax for triggerin
151151
Pusher['a_channel'].trigger('an_event', :some => 'data')
152152
```
153153

154-
This will continue to work, but has been replaced by `channels_client.trigger` which supports one or multiple channels.
154+
This will continue to work, but has been replaced by `pusher.trigger` which supports one or multiple channels.
155155

156156
### Getting information about the channels in your Pusher Channels app
157157

158158
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.
159159

160160
The following methods are provided by the gem.
161161

162-
- `channels_client.channel_info('channel_name')` returns information about that channel.
162+
- `pusher.channel_info('channel_name')` returns information about that channel.
163163

164-
- `channels_client.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
164+
- `pusher.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
165165

166-
- `channels_client.channels` returns information about all the channels in your Channels application.
166+
- `pusher.channels` returns information about all the channels in your Channels application.
167167

168168
### Asynchronous requests
169169

@@ -176,9 +176,9 @@ Asynchronous calls are supported either by using an event loop (eventmachine, pr
176176

177177
The following methods are available (in each case the calling interface matches the non-async version):
178178

179-
* `channels_client.get_async`
180-
* `channels_client.post_async`
181-
* `channels_client.trigger_async`
179+
* `pusher.get_async`
180+
* `pusher.post_async`
181+
* `pusher.trigger_async`
182182

183183
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.
184184

@@ -190,7 +190,7 @@ It is of course also possible to make calls to the Channels HTTP API via a job q
190190
The `_async` methods return an `EM::Deferrable` which you can bind callbacks to:
191191

192192
``` ruby
193-
channels_client.get_async("/channels").callback { |response|
193+
pusher.get_async("/channels").callback { |response|
194194
# use reponse[:channels]
195195
}.errback { |error|
196196
# error is an instance of Pusher::Error
@@ -213,15 +213,15 @@ It's possible to use the gem to authenticate subscription requests to private or
213213
### Private channels
214214

215215
``` ruby
216-
channels_client.authenticate('private-my_channel', params[:socket_id])
216+
pusher.authenticate('private-my_channel', params[:socket_id])
217217
```
218218

219219
### Presence channels
220220

221221
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:
222222

223223
``` ruby
224-
channels_client.authenticate('presence-my_channel', params[:socket_id],
224+
pusher.authenticate('presence-my_channel', params[:socket_id],
225225
user_id: 'user_id',
226226
user_info: {} # optional
227227
)
@@ -232,7 +232,7 @@ channels_client.authenticate('presence-my_channel', params[:socket_id],
232232
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).
233233

234234
``` ruby
235-
webhook = channels_client.webhook(request)
235+
webhook = pusher.webhook(request)
236236
if webhook.valid?
237237
webhook.events.each do |event|
238238
case event["name"]

0 commit comments

Comments
 (0)