Skip to content

Commit

Permalink
Presence.get should verify if the channel state is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Sep 29, 2016
1 parent 8013e70 commit 70bf363
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/ARTRealtimePresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ - (void)get:(void (^)(NSArray<ARTPresenceMessage *> *, ARTErrorInfo *))callback

- (void)get:(ARTRealtimePresenceQuery *)query callback:(void (^)(NSArray<ARTPresenceMessage *> *, ARTErrorInfo *))callback {
[_channel throwOnDisconnectedOrFailed];

switch (_channel.state) {
case ARTRealtimeChannelFailed:
case ARTRealtimeChannelDetached:
if (callback) callback(nil, [ARTErrorInfo createWithCode:0 message:@"invalid channel state"]);
return;
default:
break;
}

[_channel attach:^(ARTErrorInfo *error) {
if (error) {
callback(nil, error);
Expand Down

0 comments on commit 70bf363

Please sign in to comment.