Skip to content

Commit 206835c

Browse files
authored
Merge pull request #257 from pusher/dev-force-to-use-2
Refactor PusherOptions forceTLS to useTLS
2 parents c85f492 + 28d66af commit 206835c

File tree

9 files changed

+32
-36
lines changed

9 files changed

+32
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# pusher-websocket-java changelog
22

3+
### Version 2.2.1 - 22nd April 2020
4+
5+
* Changed PusherOptions `setForceTLS` and `isForceTLS` to `setUseTLS` and `isUseTLS` to align with the other client SDKs.
6+
37
## Version 2.2.0 - 22nd April 2020
48

59
* Changed PusherOptions `setEncrypted` and `isEncrypted` to `setForceTLS` and `isForceTLS` to reduce confusion between this option and private encrypted channels.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The pusher-java-client is available in Maven Central.
6161
<dependency>
6262
<groupId>com.pusher</groupId>
6363
<artifactId>pusher-java-client</artifactId>
64-
<version>2.2.0</version>
64+
<version>2.2.1</version>
6565
</dependency>
6666
</dependencies>
6767
```
@@ -70,7 +70,7 @@ The pusher-java-client is available in Maven Central.
7070

7171
```groovy
7272
dependencies {
73-
compile 'com.pusher:pusher-java-client:2.2.0'
73+
compile 'com.pusher:pusher-java-client:2.2.1'
7474
}
7575
```
7676

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ apply plugin: 'signing'
2222
apply plugin: 'jacoco'
2323

2424
group = "com.pusher"
25-
version = "2.2.0"
25+
version = "2.2.1"
2626
sourceCompatibility = "1.8"
2727
targetCompatibility = "1.8"
2828

src/main/java/com/pusher/client/PusherOptions.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class PusherOptions {
3434
private String host = "ws.pusherapp.com";
3535
private int wsPort = WS_PORT;
3636
private int wssPort = WSS_PORT;
37-
private boolean forceTLS = true;
37+
private boolean useTLS = true;
3838
private long activityTimeout = DEFAULT_ACTIVITY_TIMEOUT;
3939
private long pongTimeout = DEFAULT_PONG_TIMEOUT;
4040
private Authorizer authorizer;
@@ -44,38 +44,38 @@ public class PusherOptions {
4444

4545
/**
4646
* @deprecated
47-
* Please use isForceTLS
47+
* Please use isUseTLS
4848
*/
4949
@Deprecated
5050
public boolean isEncrypted() {
51-
return forceTLS;
51+
return useTLS;
5252
}
5353

5454
/**
5555
* @deprecated
56-
* Please use setForceTLS
56+
* Please use setUseTLS
5757
*/
5858
@Deprecated
5959
public PusherOptions setEncrypted(final boolean encrypted) {
60-
this.forceTLS = encrypted;
60+
this.useTLS = encrypted;
6161
return this;
6262
}
6363

6464
/**
6565
*
6666
* @return whether the connection to Pusher should use TLS
6767
*/
68-
public boolean isForceTLS() {
69-
return forceTLS;
68+
public boolean isUseTLS() {
69+
return useTLS;
7070
}
7171

7272
/**
7373
* Sets whether the connection to Pusher should be use TLS.
74-
* @param forceTLS whether the connection should use TLS, by default this is true
74+
* @param useTLS whether the connection should use TLS, by default this is true
7575
* @return this, for chaining
7676
*/
77-
public PusherOptions setForceTLS(final boolean forceTLS) {
78-
this.forceTLS = forceTLS;
77+
public PusherOptions setUseTLS(final boolean useTLS) {
78+
this.useTLS = useTLS;
7979
return this;
8080
}
8181

@@ -237,7 +237,7 @@ public long getPongTimeout() {
237237
* @return the WebSocket URL
238238
*/
239239
public String buildUrl(final String apiKey) {
240-
return String.format("%s://%s:%s/app/%s%s", forceTLS ? WSS_SCHEME : WS_SCHEME, host, forceTLS ? wssPort
240+
return String.format("%s://%s:%s/app/%s%s", useTLS ? WSS_SCHEME : WS_SCHEME, host, useTLS ? wssPort
241241
: wsPort, apiKey, URI_SUFFIX);
242242
}
243243

src/main/java/com/pusher/client/example/ExampleApp.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package com.pusher.client.example;
22

3-
import java.util.Map;
4-
5-
import com.google.gson.Gson;
6-
73
import com.pusher.client.Pusher;
84
import com.pusher.client.PusherOptions;
95
import com.pusher.client.channel.Channel;
@@ -47,7 +43,7 @@ public ExampleApp(final String[] args) {
4743

4844
// configure your Pusher connection with the options you want
4945
final PusherOptions options = new PusherOptions()
50-
.setForceTLS(true)
46+
.setUseTLS(true)
5147
.setCluster(cluster);
5248
Pusher pusher = new Pusher(channelsKey, options);
5349

src/main/java/com/pusher/client/example/PresenceChannelExampleApp.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import com.pusher.client.Pusher;
66
import com.pusher.client.PusherOptions;
7-
import com.pusher.client.channel.PrivateChannelEventListener;
87
import com.pusher.client.channel.PusherEvent;
98
import com.pusher.client.channel.PresenceChannel;
109
import com.pusher.client.channel.PresenceChannelEventListener;
@@ -56,7 +55,7 @@ private PresenceChannelExampleApp(final String[] args) {
5655

5756
// configure your Pusher connection with the options you want
5857
final PusherOptions options = new PusherOptions()
59-
.setForceTLS(true)
58+
.setUseTLS(true)
6059
.setCluster(cluster)
6160
.setAuthorizer(authorizer);
6261
Pusher pusher = new Pusher(channelsKey, options);

src/main/java/com/pusher/client/example/PrivateChannelExampleApp.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import com.pusher.client.Pusher;
44
import com.pusher.client.PusherOptions;
5-
import com.pusher.client.channel.Channel;
6-
import com.pusher.client.channel.ChannelEventListener;
75
import com.pusher.client.channel.PusherEvent;
86
import com.pusher.client.channel.PrivateChannel;
97
import com.pusher.client.channel.PrivateChannelEventListener;
@@ -54,7 +52,7 @@ public static void main(final String[] args) {
5452

5553
// configure your Pusher connection with the options you want
5654
final PusherOptions options = new PusherOptions()
57-
.setForceTLS(true)
55+
.setUseTLS(true)
5856
.setCluster(cluster)
5957
.setAuthorizer(authorizer);
6058
Pusher pusher = new Pusher(channelsKey, options);

src/main/java/com/pusher/client/example/PrivateEncryptedChannelExampleApp.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.pusher.client.Pusher;
44
import com.pusher.client.PusherOptions;
5-
import com.pusher.client.channel.PrivateChannelEventListener;
65
import com.pusher.client.channel.PrivateEncryptedChannel;
76
import com.pusher.client.channel.PrivateEncryptedChannelEventListener;
87
import com.pusher.client.channel.PusherEvent;
@@ -60,7 +59,7 @@ private PrivateEncryptedChannelExampleApp(final String[] args) {
6059
final PusherOptions options = new PusherOptions()
6160
.setCluster(cluster)
6261
.setAuthorizer(authorizer)
63-
.setForceTLS(true);
62+
.setUseTLS(true);
6463
Pusher pusher = new Pusher(channelsKey, options);
6564

6665
// set up a ConnectionEventListener to listen for connection changes to Pusher

src/test/java/com/pusher/client/PusherOptionsTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public void testEncryptedInitializedAsTrue() {
3232
}
3333

3434
@Test
35-
public void testForceTLSInitializedAsTrue() {
36-
assert pusherOptions.isForceTLS();
35+
public void testUseTLSInitializedAsTrue() {
36+
assert pusherOptions.isUseTLS();
3737
}
3838

3939
@Test
@@ -54,9 +54,9 @@ public void testEncryptedCanBeSetToTrue() {
5454
}
5555

5656
@Test
57-
public void testForceTLSCanBeSetToTrue() {
58-
pusherOptions.setForceTLS(true);
59-
assertSame(true, pusherOptions.isForceTLS());
57+
public void testUseTLSCanBeSetToTrue() {
58+
pusherOptions.setUseTLS(true);
59+
assertSame(true, pusherOptions.isUseTLS());
6060
}
6161

6262
@Test
@@ -70,8 +70,8 @@ public void testSetEncryptedReturnsSelf() {
7070
}
7171

7272
@Test
73-
public void testSetForceTLSReturnsSelf() {
74-
assertSame(pusherOptions, pusherOptions.setForceTLS(true));
73+
public void testSetUseTLSReturnsSelf() {
74+
assertSame(pusherOptions, pusherOptions.setUseTLS(true));
7575
}
7676

7777
@Test
@@ -82,7 +82,7 @@ public void testDefaultURL() {
8282

8383
@Test
8484
public void testNonSSLURLIsCorrect() {
85-
pusherOptions.setForceTLS(false);
85+
pusherOptions.setUseTLS(false);
8686
assertEquals(pusherOptions.buildUrl(API_KEY), "ws://ws.pusherapp.com:80/app/" + API_KEY
8787
+ "?client=java-client&protocol=5&version=" + PusherOptions.LIB_VERSION);
8888
}
@@ -96,7 +96,7 @@ public void testClusterSetURLIsCorrect() {
9696

9797
@Test
9898
public void testClusterSetNonSSLURLIsCorrect() {
99-
pusherOptions.setCluster("eu").setForceTLS(false);
99+
pusherOptions.setCluster("eu").setUseTLS(false);
100100
assertEquals(pusherOptions.buildUrl(API_KEY), "ws://ws-eu.pusher.com:80/app/" + API_KEY
101101
+ "?client=java-client&protocol=5&version=" + PusherOptions.LIB_VERSION);
102102
}
@@ -110,7 +110,7 @@ public void testCustomHostAndPortURLIsCorrect() {
110110

111111
@Test
112112
public void testCustomHostAndPortNonSSLURLIsCorrect() {
113-
pusherOptions.setHost("subdomain.example.com").setWsPort(8080).setWssPort(8181).setForceTLS(false);
113+
pusherOptions.setHost("subdomain.example.com").setWsPort(8080).setWssPort(8181).setUseTLS(false);
114114
assertEquals(pusherOptions.buildUrl(API_KEY), "ws://subdomain.example.com:8080/app/" + API_KEY
115115
+ "?client=java-client&protocol=5&version=" + PusherOptions.LIB_VERSION);
116116
}

0 commit comments

Comments
 (0)