Skip to content

Commit 0696e0b

Browse files
authored
Merge pull request #212 from pusher/revert_readme_change
Revert "readme changes"
2 parents ac34df3 + bd9544d commit 0696e0b

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
This Changelog is no longer being updated. For any further changes please see the Releases section on this Github repository - https://github.com/pusher/pusher-websocket-java/releases
44

5-
## Version 2.0.0
6-
* The onEvent handler now gets called with one parameter, called the PusherEvent. This PusherEvent has all the same information available as was available before with the 3 parameters, but now is accessible by calling getChannel(), getData() or getEventName() on the PusherEvent object you receive. In addition, for presence channel client events, you can now retrieve an authenticated User ID by calling getUserId() on the PusherEvent object. To read more on Authenticated users, see the README or our docs [here](https://pusher.com/docs/channels/using_channels/events#user-id-in-client-events).
7-
8-
95
## Version 1.4.0
106
* Update the dependency to use pusher/java-websocket fork and remove dependency on clojars.org repository.
117

README.md

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ Channel channel = pusher.subscribe("my-channel");
107107
// Bind to listen for events called "my-event" sent to "my-channel"
108108
channel.bind("my-event", new SubscriptionEventListener() {
109109
@Override
110-
public void onEvent(PusherEvent event) {
111-
System.out.println("Received event with data: " + event.toString());
110+
public void onEvent(String channel, String event, String data) {
111+
System.out.println("Received event with data: " + data);
112112
}
113113
});
114114

115-
// Disconnect from the service
115+
// Disconnect from the service (or become disconnected my network conditions)
116116
pusher.disconnect();
117117

118118
// Reconnect, with all channel subscriptions and event bindings automatically recreated
@@ -340,27 +340,6 @@ UserInfo info = gson.fromJson(jsonInfo, UserInfo.class);
340340

341341
For more information on defining the user id and user info on the server see [Implementing the auth endpoint for a presence channel](https://pusher.com/docs/channels/server_api/authenticating-users#implementing-the-auth-endpoint-for-a-presence-channel) documentation.
342342

343-
#### Client event authenticity
344-
345-
Channels now provides a 'user-id' with client events sent from the server. With presence channels, your authentication endpoint provides your user with a user-id. Previously, it was up to you to include this user-id in every client-event triggered by your clients. Now, when a client of yours triggers a client event, Channels will append their user-id to their triggered message, so that the other clients in the channel receive it. This allows you to trust that a given user really did trigger a given payload.
346-
347-
If you’d like to make use of this feature, you’ll need to extract the user-id from the message delivered by Channels. To do this, call getUserId() on the event payload your event handler gets called with, like so:
348-
349-
```java
350-
channel.bind("client-my-event", new SubscriptionEventListener() {
351-
@Override
352-
public void onEvent(PusherEvent event) {
353-
System.out.println("Received event with userId: " + event.getUserId());
354-
}
355-
});
356-
```
357-
358-
You can also instead retrieve it in the following way:
359-
360-
```java
361-
event.getProperty(“user_id”)
362-
```
363-
364343
## Binding and handling events
365344

366345
There are two types of events that occur on channel subscriptions.
@@ -380,7 +359,7 @@ Channel channel = pusher.subscribe("my-channel", new ChannelEventListener() {
380359
}
381360

382361
@Override
383-
public void onEvent(PusherEvent event) {
362+
public void onEvent(String channelName, String eventName, String data) {
384363
// Called for incoming events names "foo", "bar" or "baz"
385364
}
386365
}, "foo", "bar", "baz");
@@ -396,13 +375,13 @@ Events triggered by your application are received by the `onEvent` method on the
396375
Channel channel = pusher.subscribe("my-channel");
397376
channel.bind("my-event", new ChannelEventListener() {
398377
@Override
399-
public void onEvent(PusherEvent event) {
378+
public void onEvent(String channelName, String eventName, String data) {
400379
// Called for incoming events named "my-event"
401380
}
402381
});
403382
```
404383

405-
The event data is accessible by calling the `getData()` method on the event. From there you can handle the data as you like. Since we encourage data to be in JSON here's an example that uses [Gson object deserialization](https://sites.google.com/site/gson/gson-user-guide#TOC-Object-Examples):
384+
The event data will be passed as the third parameter to the `onEvent` method. From there you can handle the data as you like. Since we encourage data to be in JSON here's an example that uses [Gson object deserialization](https://sites.google.com/site/gson/gson-user-guide#TOC-Object-Examples):
406385

407386
```java
408387
public class Example implements ChannelEventListener {
@@ -413,9 +392,9 @@ public class Example implements ChannelEventListener {
413392
}
414393

415394
@Override
416-
public void onEvent(PusherEvent event) {
395+
public void onEvent(String channelName, String eventName, String data) {
417396
Gson gson = new Gson();
418-
EventExample exampleEvent = gson.fromJson(event.getData(), EventExample.class);
397+
EventExample exampleEvent = gson.fromJson(data, EventExample.class);
419398
}
420399
}
421400

0 commit comments

Comments
 (0)