Skip to content

Commit

Permalink
Event handling refactor and fix handling of pusher_internal:subscript…
Browse files Browse the repository at this point in the history
…ion_count event (#336)

* handle pusher_internal:subscription_count event internally,
but pass it on to the handlers. Also create the public
pusher:subscription_count event

* - refactor pusher event handling
- formatting
- fix subscriptioncount

* formatting

* update changelog and readme

Co-authored-by: Niek <[email protected]>
Co-authored-by: proggen-com <[email protected]>
  • Loading branch information
3 people authored Sep 13, 2022
1 parent 5c484c4 commit a8e9594
Show file tree
Hide file tree
Showing 94 changed files with 2,331 additions and 2,150 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name: pusher-websocket-java CI
on:
pull_request:
push:
branches: [master, main]
branches: [ master, main ]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
java-version: [8, 9, 10, 11, 17, 18]
java-version: [ 8, 9, 10, 11, 17, 18 ]

steps:
- uses: actions/[email protected]
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# pusher-websocket-java changelog

### Version 2.4.1 - 13th Sep 2022
* Refactoring and code cleanup of event handling in the SDK
* Fixes subscription_count events

### Version 2.4.0 - 15th July 2022
* Add support for Subscription count events

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The pusher-java-client is available in Maven Central.
<dependency>
<groupId>com.pusher</groupId>
<artifactId>pusher-java-client</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
</dependency>
</dependencies>
```
Expand All @@ -83,7 +83,7 @@ The pusher-java-client is available in Maven Central.

```groovy
dependencies {
compile 'com.pusher:pusher-java-client:2.4.0'
compile 'com.pusher:pusher-java-client:2.4.1'
}
```

Expand Down
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ targetCompatibility = "1.8"

ext.sharedManifest = manifest {
attributes(
'Created-By' : 'Pusher',
'Implementation-Vendor' : 'Pusher',
'Implementation-Title' : 'Pusher Java Websocket API Example',
'Implementation-Version': version,
'Package' : 'com.pusher.client.example',
'Main-Class' : 'com.pusher.client.example.ExampleApp'
'Created-By': 'Pusher',
'Implementation-Vendor': 'Pusher',
'Implementation-Title': 'Pusher Java Websocket API Example',
'Implementation-Version': version,
'Package': 'com.pusher.client.example',
'Main-Class': 'com.pusher.client.example.ExampleApp'
)
}

Expand All @@ -58,8 +58,8 @@ dependencies {

processResources {
filter(ReplaceTokens, tokens: [
version: project.version
] )
version: project.version
])
}


Expand All @@ -86,7 +86,7 @@ jar {
}
}

task fatJar(type: Jar, dependsOn:configurations.runtimeClasspath) {
task fatJar(type: Jar, dependsOn: configurations.runtimeClasspath) {
manifest = project.manifest {
from sharedManifest
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/pusher/client/Authorizer.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.pusher.client;


/**
* @deprecated
* Please use {@link com.pusher.client.ChannelAuthorizer}
* @deprecated Please use {@link com.pusher.client.ChannelAuthorizer}
*/
@Deprecated
public interface Authorizer extends ChannelAuthorizer {}
public interface Authorizer extends ChannelAuthorizer {
}
14 changes: 5 additions & 9 deletions src/main/java/com/pusher/client/ChannelAuthorizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
* </p>
*/
public interface ChannelAuthorizer {

/**
* Called when a channel subscription is to be authorized.
*
* @param channelName
* The name of the channel to be authorized.
* @param socketId
* A unique socket connection ID to be used with the
* authorization. This uniquely identifies the connection that
* the subscription is being authorized for.
* @param channelName The name of the channel to be authorized.
* @param socketId A unique socket connection ID to be used with the
* authorization. This uniquely identifies the connection that
* the subscription is being authorized for.
* @return A channel authorization token.
* @throws AuthorizationFailureException
* if the authorization fails.
* @throws AuthorizationFailureException if the authorization fails.
*/
String authorize(String channelName, String socketId) throws AuthorizationFailureException;
}
27 changes: 23 additions & 4 deletions src/main/java/com/pusher/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,38 @@

public interface Client {
Connection getConnection();

void connect();

void connect(final ConnectionEventListener eventListener, ConnectionState... connectionStates);

void disconnect();

Channel subscribe(final String channelName);

Channel subscribe(final String channelName, final ChannelEventListener listener, final String... eventNames);

PrivateChannel subscribePrivate(final String channelName);
PrivateChannel subscribePrivate(final String channelName, final PrivateChannelEventListener listener,
final String... eventNames);

PrivateChannel subscribePrivate(
final String channelName,
final PrivateChannelEventListener listener,
final String... eventNames
);

PresenceChannel subscribePresence(final String channelName);
PresenceChannel subscribePresence(final String channelName, final PresenceChannelEventListener listener,
final String... eventNames);

PresenceChannel subscribePresence(
final String channelName,
final PresenceChannelEventListener listener,
final String... eventNames
);

void unsubscribe(final String channelName);

Channel getChannel(String channelName);

PrivateChannel getPrivateChannel(String channelName);

PresenceChannel getPresenceChannel(String channelName);
}
Loading

0 comments on commit a8e9594

Please sign in to comment.