Skip to content

Commit 5944b9a

Browse files
committed
Merge branch 'master' into reconnect_fix
2 parents 4a21b47 + aeb62de commit 5944b9a

File tree

17 files changed

+364
-132
lines changed

17 files changed

+364
-132
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
language: java
22
sudo: false
33
jdk:
4-
- oraclejdk8
4+
- openjdk8
5+
- openjdk9
6+
- openjdk10
7+
- openjdk11
58
script:
69
- ./gradlew test

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
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 getChannelName(), 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+
59
## Version 1.4.0
610
* Update the dependency to use pusher/java-websocket fork and remove dependency on clojars.org repository.
711

812
## Version 1.3.0
913
* Add retry logic when the connection is lost
10-
* Accept 201 status code from auth endpoints
14+
* Accept 201 status code from auth endpoints
1115

1216
## Version 1.2.2
1317

README.md

Lines changed: 70 additions & 28 deletions
Large diffs are not rendered by default.

build.gradle

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ apply plugin: 'signing'
2222

2323
group = "com.pusher"
2424
version = "1.8.2-SNAPSHOT"
25-
sourceCompatibility = "1.6"
26-
targetCompatibility = "1.6"
25+
sourceCompatibility = "1.8"
26+
targetCompatibility = "1.8"
2727

2828
ext.sharedManifest = manifest {
2929
attributes(
@@ -127,60 +127,62 @@ artifacts {
127127
archives jar, fatJar, sourcesJar, javadocJar
128128
}
129129

130-
task createPublishTarget << {
131-
uploadArchives { repositories { mavenDeployer {
132-
beforeDeployment {
133-
MavenDeployment deployment -> signing.signPom(deployment)
134-
}
135-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
136-
authentication(
137-
userName: getProperty("maven.username"),
138-
password: getProperty("maven.password")
139-
)
140-
}
141-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
142-
authentication(
143-
userName: getProperty("maven.username"),
144-
password: getProperty("maven.password")
145-
)
146-
}
147-
pom.project {
148-
name 'Pusher Java Client Library'
149-
packaging 'jar'
150-
artifactId 'pusher-java-client'
151-
description 'This is a Java client library for Pusher, targeted at core Java and Android.'
152-
url 'http://github.com/pusher/pusher-websocket-java'
153-
scm {
154-
connection 'scm:git:git@github.com:pusher/pusher-websocket-java'
155-
developerConnection 'scm:git:git@github.com:pusher/pusher-websocket-java'
156-
url 'http://github.com/pusher/pusher-websocket-java'
157-
}
158-
licenses {
159-
license {
160-
name 'MIT'
161-
url 'https://raw.github.com/pusher/pusher-websocket-java/master/LICENCE.txt'
162-
distribution 'https://raw.github.com/pusher/pusher-websocket-java/mvn-repo/'
163-
}
130+
task createPublishTarget {
131+
doLast {
132+
uploadArchives { repositories { mavenDeployer {
133+
beforeDeployment {
134+
MavenDeployment deployment -> signing.signPom(deployment)
164135
}
165-
organization {
166-
name 'Pusher'
167-
url 'http://pusher.com'
136+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
137+
authentication(
138+
userName: getProperty("maven.username"),
139+
password: getProperty("maven.password")
140+
)
168141
}
169-
issueManagement {
170-
system 'GitHub'
171-
url 'https://github.com/pusher/pusher-websocket-java/issues'
142+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
143+
authentication(
144+
userName: getProperty("maven.username"),
145+
password: getProperty("maven.password")
146+
)
172147
}
173-
developers {
174-
developer {
175-
id 'mike'
176-
name 'Mike Pye'
177-
email 'mike@pusher.com'
148+
pom.project {
149+
name 'Pusher Java Client Library'
150+
packaging 'jar'
151+
artifactId 'pusher-java-client'
152+
description 'This is a Java client library for Pusher, targeted at core Java and Android.'
153+
url 'http://github.com/pusher/pusher-websocket-java'
154+
scm {
155+
connection 'scm:git:git@github.com:pusher/pusher-websocket-java'
156+
developerConnection 'scm:git:git@github.com:pusher/pusher-websocket-java'
157+
url 'http://github.com/pusher/pusher-websocket-java'
158+
}
159+
licenses {
160+
license {
161+
name 'MIT'
162+
url 'https://raw.github.com/pusher/pusher-websocket-java/master/LICENCE.txt'
163+
distribution 'https://raw.github.com/pusher/pusher-websocket-java/mvn-repo/'
164+
}
165+
}
166+
organization {
167+
name 'Pusher'
168+
url 'http://pusher.com'
169+
}
170+
issueManagement {
171+
system 'GitHub'
172+
url 'https://github.com/pusher/pusher-websocket-java/issues'
173+
}
174+
developers {
175+
developer {
176+
id 'mike'
177+
name 'Mike Pye'
178+
email 'mike@pusher.com'
179+
}
178180
}
179181
}
180-
}
181-
}}}
182+
}}}
183+
}
182184
}
183185

184-
task wrapper(type: Wrapper) {
185-
gradleVersion = '4.4.1'
186+
wrapper {
187+
gradleVersion = '5.5.1'
186188
}

gradle/wrapper/gradle-wrapper.jar

1.25 KB
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Wed Feb 21 14:42:32 GMT 2018
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip

gradlew

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env sh
22

3+
#
4+
# Copyright 2015 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
319
##############################################################################
420
##
521
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
2844
APP_BASE_NAME=`basename "$0"`
2945

3046
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
47+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
3248

3349
# Use the maximum available, or set MAX_FD != -1 to use that value.
3450
MAX_FD="maximum"

gradlew.bat

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
117
@if "%DEBUG%" == "" @echo off
218
@rem ##########################################################################
319
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
1430
set APP_HOME=%DIRNAME%
1531

1632
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17-
set DEFAULT_JVM_OPTS=
33+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
1834

1935
@rem Find java.exe
2036
if defined JAVA_HOME goto findJavaFromJavaHome
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.pusher.client.channel;
2+
3+
import java.util.Map;
4+
5+
public class PusherEvent {
6+
private Map<String, Object> eventData;
7+
8+
public PusherEvent(Map<String, Object> eventData) {
9+
this.eventData = eventData;
10+
}
11+
12+
/**
13+
* getProperty returns the value associated with the key, or null.
14+
* It is recommended that you use the specialized getters in this class instead.
15+
*
16+
* @param key The key you wish to get.
17+
* @return
18+
* The object can be casted as follows:
19+
* - JSON strings - java.lang.String
20+
* - JSON number - java.lang.Double
21+
* - JSON boolean - java.lang.Boolean
22+
* - JSON array - java.util.ArrayList
23+
* - JSON object - java.util.Map
24+
* - JSON null - null
25+
*/
26+
public Object getProperty(String key) {
27+
return eventData.get(key);
28+
}
29+
30+
/**
31+
* Returns the userId associated with this event.
32+
*
33+
* @return
34+
* The userID string: https://pusher.com/docs/channels/using_channels/events#user-id-in-client-events,
35+
* or null if the event is not a client event on a presence channel.
36+
*/
37+
public String getUserId() { return (String)eventData.get("user_id"); }
38+
public String getChannelName() { return (String)eventData.get("channel"); }
39+
public String getEventName() { return (String)eventData.get("event"); }
40+
public String getData() { return (String)eventData.get("data"); }
41+
42+
public String toString() {
43+
return eventData.toString();
44+
}
45+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.pusher.client.channel;
2+
3+
import java.lang.reflect.Type;
4+
import java.util.Map;
5+
6+
import com.google.gson.Gson;
7+
import com.google.gson.JsonDeserializationContext;
8+
import com.google.gson.JsonDeserializer;
9+
import com.google.gson.JsonElement;
10+
import com.google.gson.JsonParseException;
11+
12+
public class PusherEventDeserializer implements JsonDeserializer<PusherEvent> {
13+
private final Gson GSON = new Gson();
14+
15+
@Override
16+
@SuppressWarnings("unchecked")
17+
public PusherEvent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
18+
return new PusherEvent(GSON.fromJson(json, Map.class));
19+
}
20+
}

0 commit comments

Comments
 (0)