Skip to content

Commit

Permalink
simplified: server sends usermeta in case of presence event
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Apr 15, 2024
1 parent 45e793e commit 98683ad
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
17 changes: 0 additions & 17 deletions pubnub/lib/src/subscribe/envelope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,6 @@ class PresenceEvent {
.map((uuid) => UUID(uuid))
.toList();

static bool isValidPresenceEvent(Envelope envelope) {
final payload = envelope.payload;
if (payload is! Map) return false;

final action = payload['action'];
final occupancy = payload['occupancy'];

if (action is! String ||
PresenceActionExtension.fromString(action) == PresenceAction.unknown) {
return false;
}
if (occupancy is! int) {
return false;
}
return true;
}

PresenceEvent.fromEnvelope(this.envelope)
: action = PresenceActionExtension.fromString(
envelope.payload['action'] as String),
Expand Down
2 changes: 1 addition & 1 deletion pubnub/lib/src/subscribe/subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Subscription {
/// Will only emit when [withPresence] is true.
Stream<PresenceEvent> get presence => _envelopesController.stream
.where((envelope) =>
PresenceEvent.isValidPresenceEvent(envelope) &&
envelope.userMeta != null &&
(presenceChannels.contains(envelope.channel) ||
presenceChannels.contains(envelope.subscriptionPattern) ||
presenceChannelGroups.contains(envelope.subscriptionPattern)))
Expand Down

0 comments on commit 98683ad

Please sign in to comment.