Skip to content

Commit faaf491

Browse files
author
proggen
committed
* Add subcription count event handling
* Update packages
1 parent 669b4dc commit faaf491

File tree

13 files changed

+226
-39
lines changed

13 files changed

+226
-39
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ a minimal application to connect to a channel and send events.
4747
- [`onSubscriptionSucceeded`](#onsubscriptionsucceeded)
4848
- [`onSubscriptionError`](#onsubscriptionerror)
4949
- [`onDecryptionFailure`](#ondecryptionfailure)
50+
- [`onSubscriptionCount`](#onsubscriptioncount)
5051
- [`onMemberAdded`](#onmemberadded)
5152
- [`onMemberRemoved`](#onmemberremoved)
5253
- [`onAuthorizer`](#onauthorizer)
@@ -230,6 +231,17 @@ function onDecryptionFailure(event:string, string reason:string) {
230231
```
231232
Used with private channels only. Use this if you want to be notified if any messages fail to decrypt.
232233

234+
#### `onSubscriptionCount`
235+
236+
```typescript
237+
function onSubscriptionCount(subscriptionCount:number) {
238+
console.log(`onSubscriptionSucceeded: ${subscriptionCount}`);
239+
}
240+
```
241+
242+
is an event that can be manually enabled on the server to count the number of connections that are currently subscribed to a particular channel. They work with all channel types, except presence channels.
243+
See [Counting live users at scale with subscription_count events](https://blog.pusher.com/counting-live-users-at-scale-with-subscription-count-events/) for more information.
244+
233245
#### `onMemberAdded`
234246

235247
```typescript

android/gradle.properties

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1-
PusherWebsocketReactNative_kotlinVersion=1.3.50
2-
PusherWebsocketReactNative_compileSdkVersion=29
3-
PusherWebsocketReactNative_targetSdkVersion=29
1+
## For more details on how to configure your build environment visit
2+
# http://www.gradle.org/docs/current/userguide/build_environment.html
3+
#
4+
# Specifies the JVM arguments used for the daemon process.
5+
# The setting is particularly useful for tweaking memory settings.
6+
# Default value: -Xmx1024m -XX:MaxPermSize=256m
7+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8+
#
9+
# When configured, Gradle will run in incubating parallel mode.
10+
# This option should only be used with decoupled projects. More details, visit
11+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
12+
# org.gradle.parallel=true
13+
#Fri Aug 19 11:19:42 CEST 2022
14+
PusherWebsocketReactNative_kotlinVersion=1.7.10
15+
PusherWebsocketReactNative_targetSdkVersion=32
16+
PusherWebsocketReactNative_compileSdkVersion=32
17+
android.useAndroidX=true
18+
android.enableJetifier=true

android/src/main/java/com/pusherwebsocketreactnative/PusherWebsocketReactNativeModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class PusherWebsocketReactNativeModule(reactContext: ReactApplicationContext) :
6565
if (arguments.hasKey("useTLS")) options.isUseTLS =
6666
arguments.getBoolean("useTLS")
6767
if (arguments.hasKey("activityTimeout")) options.activityTimeout =
68-
arguments.getInt("activityTimeout") as Long
68+
arguments.getInt("activityTimeout").toLong()
6969
if (arguments.hasKey("pongTimeout")) options.pongTimeout =
70-
arguments.getInt("pongTimeout") as Long
70+
arguments.getInt("pongTimeout").toLong()
7171
if (arguments.hasKey("maxReconnectionAttempts")) options.maxReconnectionAttempts =
7272
arguments.getInt("maxReconnectionAttempts")
7373
if (arguments.hasKey("maxReconnectGapInSeconds")) options.maxReconnectGapInSeconds =

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ dependencies {
205205
implementation jscFlavor
206206
}
207207

208-
implementation project(':pusherwebsocketreactnative')
208+
implementation project(':pusher-websocket-react-native')
209209
}
210210

211211
// Run this once to be able to run the application with BUCK

example/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
buildscript {
44
ext {
55
minSdkVersion = 21
6-
compileSdkVersion = 31
7-
targetSdkVersion = 31
6+
compileSdkVersion = 32
7+
targetSdkVersion = 32
88
}
99
repositories {
1010
google()
1111
mavenCentral()
1212
}
1313
dependencies {
14-
classpath('com.android.tools.build:gradle:7.2.0')
14+
classpath('com.android.tools.build:gradle:7.2.1')
1515

1616
// NOTE: Do not place your application dependencies here; they belong
1717
// in the individual module build.gradle files

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
android.useAndroidX=true
2121
android.enableJetifier=true
22-
FLIPPER_VERSION=0.142.0
22+
FLIPPER_VERSION=0.159.0

example/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
"start": "npx react-native start"
1010
},
1111
"dependencies": {
12-
"@react-native-async-storage/async-storage": "^1.17.5",
12+
"@react-native-async-storage/async-storage": "^1.17.9",
1313
"crypto-es": "^1.2.7",
1414
"react": "17.0.2",
15-
"react-native": "0.68.2"
15+
"react-native": "0.68.3"
1616
},
1717
"devDependencies": {
18-
"@babel/core": "^7.18.0",
19-
"@babel/runtime": "^7.18.0",
18+
"@babel/core": "^7.18.10",
19+
"@babel/runtime": "^7.18.9",
2020
"babel-plugin-module-resolver": "^4.1.0",
21-
"metro-react-native-babel-preset": "^0.71.0"
21+
"metro-react-native-babel-preset": "^0.72.1"
2222
}
2323
}

example/src/App.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default function App() {
7575
onEvent,
7676
onSubscriptionSucceeded,
7777
onSubscriptionError,
78+
onSubscriptionCount,
7879
onDecryptionFailure,
7980
onMemberAdded,
8081
onMemberRemoved,
@@ -114,6 +115,15 @@ export default function App() {
114115
log(`Me: ${me}`);
115116
};
116117

118+
const onSubscriptionCount = (
119+
channelName: string,
120+
subscriptionCount: Number
121+
) => {
122+
log(
123+
`onSubscriptionCount: ${subscriptionCount}, channelName: ${channelName}`
124+
);
125+
};
126+
117127
const onSubscriptionError = (
118128
channelName: string,
119129
message: string,

0 commit comments

Comments
 (0)