Skip to content

Commit 3839a1a

Browse files
committed
Merge pull request #43 from pusher/event_buffer_documentation
Added event buffer documentation for version 1.0.0
2 parents 36146e5 + 04ab9e1 commit 3839a1a

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

README.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,32 @@ contain alphanumeric characters, `-` and `_`:
5151
pusher.trigger(u'a_channel', u'an_event', {u'some': u'data'})
5252
```
5353

54-
If you wish to trigger an event on multiple channels, pass in a list as the first parameter:
54+
Triggering Events
55+
-----------------
5556

56-
```python
57-
pusher.trigger([u'a_channel', u'another_channel'], u'an_event', {u'some': u'data'})
58-
```
57+
To trigger an event on one or more channels, use the `trigger` method on the `Pusher` object.
58+
59+
#### `Pusher::trigger`
60+
61+
|Argument |Description |
62+
|:-:|:-:|
63+
|channels `String` or `Collection` |**Required** <br> The name or list of names of the channel you wish to trigger events on |
64+
|event `String`| **Required** <br> The name of the event you wish to trigger. |
65+
|data `JSONable data` | **Required** <br> The event's payload |
66+
|socket_id `String` | **Default:`None`** <br> The socket_id of the connection you wish to exclude from receiving the event. You can read more [here](http://pusher.com/docs/duplicates). |
67+
68+
|Return Values |Description |
69+
|:-:|:-:|
70+
|buffered_events `Dict` | A parsed response that includes the event_id for each event published to a channel. See example. |
71+
72+
##### Example
5973

60-
You can also specify `socket_id` as a separate argument, as described in
61-
<http://pusher.com/docs/duplicates>. This will excluded the connection with that socket_id from receiving the event:
74+
This call will trigger to `'a_channel'` and `'another_channel'`, and exclude the recipient with socket_id `"1234.12"`.
6275

6376
```python
64-
pusher.trigger(u'a_channel', u'an_event', {u'some': u'data'}, socket_id)
77+
events = pusher.trigger([u'a_channel', u'another_channel'], u'an_event', {u'some': u'data'}, "1234.12")
78+
79+
#=> {'event_ids': {'another_channel': 'eudhq17zrhfbwc', 'a_channel': 'eudhq17zrhfbtn'}}
6580
```
6681

6782
Querying Application State
@@ -215,9 +230,16 @@ webhook = pusher.config.validate_webhook(
215230
)
216231

217232
print webhook["events"]
218-
219233
```
220234

235+
## Event Buffer
236+
237+
Version 1.0.0 of the library introduced support for event buffering. The purpose of this functionality is to ensure that events that are triggered during whilst a client is offline for a short period of time will still be delivered upon reconnection.
238+
239+
Note: this requires your Pusher application to be on a cluster that has the Event Buffer capability.
240+
241+
As part of this the trigger function now returns a set of event_id values for each event triggered on a channel. These can then be used by the client to tell the Pusher service the last event it has received. If additional events have been triggered after that event ID the service has the opportunity to provide the client with those IDs.
242+
221243
Running the tests
222244
-----------------
223245

0 commit comments

Comments
 (0)