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
Copy file name to clipboardExpand all lines: README.md
+45-35Lines changed: 45 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -19,9 +19,46 @@ gem install pusher
19
19
20
20
After registering at <http://pusher.com> configure your app with the security credentials.
21
21
22
-
### Global
22
+
### Instantiating a Pusher client
23
+
24
+
Creating a new Pusher `client` can be done as follows.
25
+
26
+
```ruby
27
+
pusher_client =Pusher::Client.new(
28
+
app_id:'your-pusher-app-id',
29
+
key:'your-pusher-key',
30
+
secret:'your-pusher-secret'
31
+
)
32
+
```
33
+
34
+
If you want to set a custom `host` value for your client then you can do so when instantiating a Pusher client like so:
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
+
```
44
+
45
+
If you created your app in a different cluster to the default cluster, you must pass the `cluster` option as follows:
46
+
47
+
```ruby
48
+
pusher_client =Pusher::Client.new(
49
+
app_id:'your-pusher-app-id',
50
+
key:'your-pusher-key',
51
+
secret:'your-pusher-secret',
52
+
cluster:'your-app-cluster'
53
+
)
54
+
```
55
+
56
+
This will set the `host` to `api-<cluster>.pusher.com`. If you pass both `host` and `cluster` options, the `host` will take precendence and `cluster` will be ignored.
57
+
58
+
### Global (Deprecated)
23
59
24
-
The most standard way of configuring Pusher is to do it globally on the Pusher class.
60
+
Configuring Pusher can also be done globally on the Pusher class.
61
+
*NOTE! This is a deprecated feature and will be removed in future versions of this library!*
25
62
26
63
```ruby
27
64
Pusher.app_id ='your-pusher-app-id'
@@ -49,33 +86,6 @@ As of version 0.12, SSL certificates are verified when using the synchronous htt
Sometimes you may have multiple sets of API keys, or want different configuration in different parts of your application. In these scenarios, a pusher `client` may be configured:
55
-
56
-
```ruby
57
-
pusher_client =Pusher::Client.new({
58
-
app_id:'your-pusher-app-id',
59
-
key:'your-pusher-key',
60
-
secret:'your-pusher-secret'
61
-
})
62
-
```
63
-
64
-
This `client` will have all the functionality listed on the main Pusher class (which proxies to a client internally).
65
-
66
-
If you want to set the `host` value for your client then you can do so when instantiating a Pusher client like so:
67
-
68
-
```ruby
69
-
pusher_client =Pusher::Client.new({
70
-
app_id:'your-pusher-app-id',
71
-
key:'your-pusher-key',
72
-
secret:'your-pusher-secret',
73
-
host:'your-pusher-host'
74
-
})
75
-
```
76
-
77
-
This is useful if, for example, you've created an app on the EU cluster and wish to set the host to be `api-eu.pusher.com`.
78
-
79
89
## Interacting with the Pusher service
80
90
81
91
The Pusher gem contains a number of helpers for interacting with the service. As a general rule, the library adheres to a set of conventions that we have aimed to make universal.
@@ -86,7 +96,7 @@ Handle errors by rescuing `Pusher::Error` (all errors are descendants of this er
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).
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:
0 commit comments