-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update RTL2 for 0.9 #543
Merged
Merged
Update RTL2 for 0.9 #543
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
891e8de
Add Realtime Channel Suspended state
ricardopereira 0c02837
Add ChannelStateChange type
ricardopereira 22f1b13
Add ProtocolMessageActionToStr method
ricardopereira c446fd9
Update RTL2
ricardopereira 340e821
RTL2f: pending
ricardopereira f41e8c8
Use ChannelStateChange on channel event emitter
ricardopereira b008a3f
Test suite: simulate client suspension with before suspension callback
ricardopereira d1ca520
Update tests using channel events
ricardopereira d97ee8f
Fix RTL14
ricardopereira a7ad1bc
Fix: Channel on suspended should transition to SUSPENDED state
ricardopereira f7a2db0
Remove RTN18
ricardopereira 036a696
Fix: set Suspended on all channels when Connection moves to Suspended
ricardopereira aa34dc0
RTL2g
ricardopereira 76a7991
Fix RTL12
ricardopereira 5cade96
Fix RTL3d
ricardopereira 6389d25
Fix: channel should reattach when connection is Connected
ricardopereira e8fefcd
Fix: should resume connection when the connection is Suspended
ricardopereira fad4c16
Fix RTN11
ricardopereira 06edc0c
Fix RTL3e
ricardopereira cd75e9e
Fix RTC8a1
ricardopereira e1ab41d
Remove testSuspendingDetachesChannel
ricardopereira 7c7c84e
Fix RTL3d
ricardopereira 3e77e18
Fix: channel is SUSPENDED then operation will result in an error
ricardopereira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,7 @@ - (void)publishProtocolMessage:(ARTProtocolMessage *)pm callback:(void (^)(ARTSt | |
[self addToQueue:pm callback:cb]; | ||
break; | ||
} | ||
case ARTRealtimeChannelSuspended: | ||
case ARTRealtimeChannelDetaching: | ||
case ARTRealtimeChannelDetached: | ||
case ARTRealtimeChannelFailed: | ||
|
@@ -180,8 +181,6 @@ - (void)publishProtocolMessage:(ARTProtocolMessage *)pm callback:(void (^)(ARTSt | |
} | ||
break; | ||
} | ||
default: | ||
NSAssert(NO, @"Invalid State"); | ||
} | ||
} | ||
|
||
|
@@ -272,19 +271,19 @@ - (void)unsubscribe:(NSString *)name listener:(ARTEventListener<ARTMessage *> *) | |
[self.messagesEventEmitter off:name listener:listener]; | ||
} | ||
|
||
- (__GENERIC(ARTEventListener, ARTErrorInfo *) *)on:(ARTChannelEvent)event callback:(void (^)(ARTErrorInfo *))cb { | ||
- (__GENERIC(ARTEventListener, ARTChannelStateChange *) *)on:(ARTChannelEvent)event callback:(void (^)(ARTChannelStateChange *))cb { | ||
return [self.statesEventEmitter on:[NSNumber numberWithInt:event] callback:cb]; | ||
} | ||
|
||
- (__GENERIC(ARTEventListener, ARTErrorInfo *) *)on:(void (^)(ARTErrorInfo *))cb { | ||
- (__GENERIC(ARTEventListener, ARTChannelStateChange *) *)on:(void (^)(ARTChannelStateChange *))cb { | ||
return [self.statesEventEmitter on:cb]; | ||
} | ||
|
||
- (__GENERIC(ARTEventListener, ARTErrorInfo *) *)once:(ARTChannelEvent)event callback:(void (^)(ARTErrorInfo *))cb { | ||
- (__GENERIC(ARTEventListener, ARTChannelStateChange *) *)once:(ARTChannelEvent)event callback:(void (^)(ARTChannelStateChange *))cb { | ||
return [self.statesEventEmitter once:[NSNumber numberWithInt:event] callback:cb]; | ||
} | ||
|
||
- (__GENERIC(ARTEventListener, ARTErrorInfo *) *)once:(void (^)(ARTErrorInfo *))cb { | ||
- (__GENERIC(ARTEventListener, ARTChannelStateChange *) *)once:(void (^)(ARTChannelStateChange *))cb { | ||
return [self.statesEventEmitter once:cb]; | ||
} | ||
|
||
|
@@ -295,11 +294,11 @@ - (void)off:(ARTChannelEvent)event listener:listener { | |
[self.statesEventEmitter off:[NSNumber numberWithInt:event] listener:listener]; | ||
} | ||
|
||
- (void)off:(__GENERIC(ARTEventListener, ARTErrorInfo *) *)listener { | ||
- (void)off:(__GENERIC(ARTEventListener, ARTChannelStateChange *) *)listener { | ||
[self.statesEventEmitter off:listener]; | ||
} | ||
|
||
- (void)emit:(ARTChannelEvent)event with:(ARTErrorInfo *)data { | ||
- (void)emit:(ARTChannelEvent)event with:(ARTChannelStateChange *)data { | ||
[self.statesEventEmitter emit:[NSNumber numberWithInt:event] with:data]; | ||
} | ||
|
||
|
@@ -308,6 +307,7 @@ - (ARTEventListener *)timed:(ARTEventListener *)listener deadline:(NSTimeInterva | |
} | ||
|
||
- (void)transition:(ARTRealtimeChannelState)state status:(ARTStatus *)status { | ||
ARTChannelStateChange *stateChange = [[ARTChannelStateChange alloc] initWithCurrent:state previous:self.state reason:status.errorInfo]; | ||
self.state = state; | ||
_errorReason = status.errorInfo; | ||
|
||
|
@@ -321,7 +321,7 @@ - (void)transition:(ARTRealtimeChannelState)state status:(ARTStatus *)status { | |
[_attachedEventEmitter emit:[NSNull null] with:[ARTErrorInfo createWithCode:90000 message:msg]]; | ||
} | ||
|
||
[self emit:(ARTChannelEvent)state with:status.errorInfo]; | ||
[self emit:(ARTChannelEvent)stateChange.current with:stateChange]; | ||
} | ||
|
||
- (void)dealloc { | ||
|
@@ -339,7 +339,8 @@ - (void)unlessStateChangesBefore:(NSTimeInterval)deadline do:(void(^)())callback | |
// Already changed; do nothing. | ||
return; | ||
} | ||
[self timed:[self once:^(ARTErrorInfo *errorInfo) { | ||
// FIXME: should not use the global listener for internal purpose | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you raise an issue for this so it's not forgotten? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done #555. |
||
[self timed:[self once:^(ARTChannelStateChange *stateChange) { | ||
// Any state change cancels the timeout. | ||
}] deadline:deadline onTimeout:callback]; | ||
}); | ||
|
@@ -397,8 +398,8 @@ - (void)setAttached:(ARTProtocolMessage *)message { | |
if (self.state == ARTRealtimeChannelAttached) { | ||
if (message.error != nil) { | ||
_errorReason = message.error; | ||
[self emit:ARTChannelEventUpdate with:message.error]; | ||
} | ||
[self emit:ARTChannelEventUpdate with:[[ARTChannelStateChange alloc] initWithCurrent:self.state previous:self.state reason:message.error]]; | ||
return; | ||
} | ||
|
||
|
@@ -448,7 +449,7 @@ - (void)setFailed:(ARTStatus *)error { | |
|
||
- (void)setSuspended:(ARTStatus *)error { | ||
[self failQueuedMessages:error]; | ||
[self transition:ARTRealtimeChannelDetached status:error]; | ||
[self transition:ARTRealtimeChannelSuspended status:error]; | ||
} | ||
|
||
- (void)onMessage:(ARTProtocolMessage *)message { | ||
|
@@ -463,7 +464,7 @@ - (void)onMessage:(ARTProtocolMessage *)message { | |
ARTErrorInfo *errorInfo = [ARTErrorInfo wrap:(ARTErrorInfo *)error.userInfo[NSLocalizedFailureReasonErrorKey] prepend:@"Failed to decode data: "]; | ||
[self.logger error:@"R:%p C:%p %@", _realtime, self, errorInfo.message]; | ||
_errorReason = errorInfo; | ||
[self emit:ARTChannelEventUpdate with:errorInfo]; | ||
[self emit:ARTChannelEventUpdate with:[[ARTChannelStateChange alloc] initWithCurrent:self.state previous:self.state reason:errorInfo]]; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not worth adding Auth here now so that we don't forget, or at least a TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.