File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
android/src/main/java/com/pusherwebsocketreactnative Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -160,8 +160,7 @@ class PusherWebsocketReactNativeModule(reactContext: ReactApplicationContext) :
160
160
authorizerMutex[key]!! .acquire()
161
161
val authParams = authorizerResult.remove(key)!!
162
162
val gson = Gson ()
163
- val json = gson.toJson(authParams.toHashMap())
164
- return json
163
+ return gson.toJson(authParams.toHashMap())
165
164
}
166
165
167
166
@ReactMethod
@@ -198,12 +197,23 @@ class PusherWebsocketReactNativeModule(reactContext: ReactApplicationContext) :
198
197
199
198
override fun onEvent (event : PusherEvent ) {
200
199
// Log.i(TAG, "Received event with data: $event")
200
+ // The java sdk transforms some events from pusher_internal
201
+ // to pusher:... events, we translate them back.
202
+ val finalEvent = if (event.eventName == = " pusher:subscription_count" ) {
203
+ PusherEvent (
204
+ " pusher_internal:subscription_count" ,
205
+ event.channelName,
206
+ event.userId,
207
+ event.data)
208
+ } else {
209
+ event
210
+ }
201
211
emitEvent(
202
212
" onEvent" , mapOf (
203
- " channelName" to event .channelName,
204
- " eventName" to event .eventName,
205
- " userId" to event .userId,
206
- " data" to event .data
213
+ " channelName" to finalEvent .channelName,
214
+ " eventName" to finalEvent .eventName,
215
+ " userId" to finalEvent .userId,
216
+ " data" to finalEvent .data
207
217
)
208
218
)
209
219
}
You can’t perform that action at this time.
0 commit comments