-
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
Test suite websocket #169
Merged
Merged
Test suite websocket #169
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
54262e7
Enhance: (Realtime) onHeartbeat and onDisconnected are not using the …
ricardopereira b2b4e87
Tests should avoid `transition` because it will miss some logic
ricardopereira 7430606
Test suite: added Realtime.fail()
ricardopereira 4e80196
Fix: Realtime.onDisconnected should not reset `msgSerial`
ricardopereira ef9e0ed
Test suite: simulateIncomingNormalClose, simulateIncomingAbruptlyClos…
ricardopereira e7924eb
Test suite: `transition` must be private
ricardopereira 6625ddc
Realtime: each Transport Event receive the protocol message which has…
ricardopereira 242c800
Updated RTN4a with valid state flow
ricardopereira 5a6072c
Unused variable
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,7 +446,7 @@ -(void) cancelPingTimer { | |
self.pingTimeout = nil; | ||
} | ||
|
||
- (void)onHeartbeat:(ARTProtocolMessage *)message { | ||
- (void)onHeartbeat { | ||
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. Why did you remove the ProtocolMessage? 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. Because the method was not using it. |
||
[self.logger verbose:@"ARTRealtime heartbeat received"]; | ||
if(self.pingCb) { | ||
[self cancelPingTimer]; | ||
|
@@ -461,15 +461,15 @@ - (void)onHeartbeat:(ARTProtocolMessage *)message { | |
} | ||
} | ||
|
||
- (void)onConnected:(ARTProtocolMessage *)message withErrorInfo:(ARTErrorInfo *)errorInfo { | ||
- (void)onConnected:(ARTProtocolMessage *)message { | ||
// Resuming | ||
if ([self isFromResume]) { | ||
if (errorInfo && ![message.connectionId isEqualToString:self.connectionId]) { | ||
if (message.error && ![message.connectionId isEqualToString:self.connectionId]) { | ||
[self.logger warn:@"ARTRealtime: connection has reconnected, but resume failed. Detaching all channels"]; | ||
// Fatal error, detach all channels | ||
for (NSString *channelName in self.allChannels) { | ||
ARTRealtimeChannel *channel = [self.allChannels objectForKey:channelName]; | ||
[channel detachChannel:[ARTStatus state:ARTStateConnectionDisconnected info:errorInfo]]; | ||
[channel detachChannel:[ARTStatus state:ARTStateConnectionDisconnected info:message.error]]; | ||
} | ||
|
||
self.options.resumeKey = nil; | ||
|
@@ -481,8 +481,8 @@ - (void)onConnected:(ARTProtocolMessage *)message withErrorInfo:(ARTErrorInfo *) | |
} | ||
} | ||
} | ||
else if (errorInfo) { | ||
[self.logger warn:@"ARTRealtime: connection has resumed with non-fatal error %@", errorInfo.message]; | ||
else if (message.error) { | ||
[self.logger warn:@"ARTRealtime: connection has resumed with non-fatal error %@", message.error.message]; | ||
// The error will be emitted on `transition` | ||
} | ||
} | ||
|
@@ -496,7 +496,7 @@ - (void)onConnected:(ARTProtocolMessage *)message withErrorInfo:(ARTErrorInfo *) | |
self.msgSerial = 0; | ||
self.pendingMessageStartSerial = 0; | ||
} | ||
[self transition:ARTRealtimeConnected withErrorInfo:errorInfo]; | ||
[self transition:ARTRealtimeConnected withErrorInfo:message.error]; | ||
break; | ||
default: | ||
NSAssert(false, @"Invalid Realtime state: expected Connecting has current state"); | ||
|
@@ -512,12 +512,11 @@ - (NSString *)connectionId { | |
return _connectionId; | ||
} | ||
|
||
- (void)onDisconnected:(ARTProtocolMessage *)message { | ||
- (void)onDisconnected { | ||
[self.logger info:@"ARTRealtime disconnected"]; | ||
switch (self.state) { | ||
case ARTRealtimeConnected: | ||
self.connectionId = nil; | ||
self.msgSerial = 0; | ||
[self transition:ARTRealtimeDisconnected]; | ||
break; | ||
default: | ||
|
@@ -526,13 +525,13 @@ - (void)onDisconnected:(ARTProtocolMessage *)message { | |
} | ||
} | ||
|
||
- (void)onError:(ARTProtocolMessage *)message withErrorInfo:(ARTErrorInfo *)errorInfo { | ||
- (void)onError:(ARTProtocolMessage *)message { | ||
// TODO work out which states this can be received in | ||
if (message.channel) { | ||
[self onChannelMessage:message withErrorInfo:errorInfo]; | ||
[self onChannelMessage:message]; | ||
} else { | ||
self.connectionId = nil; | ||
[self transition:ARTRealtimeFailed withErrorInfo:errorInfo]; | ||
[self transition:ARTRealtimeFailed withErrorInfo:message.error]; | ||
} | ||
} | ||
|
||
|
@@ -544,7 +543,7 @@ - (void)onNack:(ARTProtocolMessage *)message { | |
[self nack:message]; | ||
} | ||
|
||
- (void)onChannelMessage:(ARTProtocolMessage *)message withErrorInfo:(ARTErrorInfo *)errorInfo { | ||
- (void)onChannelMessage:(ARTProtocolMessage *)message { | ||
// TODO work out which states this can be received in / error info? | ||
ARTRealtimeChannel *channel = [self.allChannels objectForKey:message.channel]; | ||
[channel onChannelMessage:message]; | ||
|
@@ -805,19 +804,19 @@ - (void)realtimeTransport:(id)transport didReceiveMessage:(ARTProtocolMessage *) | |
|
||
switch (message.action) { | ||
case ARTProtocolMessageHeartbeat: | ||
[self onHeartbeat:message]; | ||
[self onHeartbeat]; | ||
break; | ||
case ARTProtocolMessageError: | ||
[self onError:message withErrorInfo:message.error]; | ||
[self onError:message]; | ||
break; | ||
case ARTProtocolMessageConnected: | ||
// Set Auth#clientId | ||
[[self auth] setProtocolClientId:message.clientId]; | ||
// Event | ||
[self onConnected:message withErrorInfo:message.error]; | ||
[self onConnected:message]; | ||
break; | ||
case ARTProtocolMessageDisconnected: | ||
[self onDisconnected:message]; | ||
[self onDisconnected]; | ||
break; | ||
case ARTProtocolMessageAck: | ||
[self onAck:message]; | ||
|
@@ -829,7 +828,7 @@ - (void)realtimeTransport:(id)transport didReceiveMessage:(ARTProtocolMessage *) | |
[self transition:ARTRealtimeClosed]; | ||
break; | ||
default: | ||
[self onChannelMessage:message withErrorInfo:message.error]; | ||
[self onChannelMessage:message]; | ||
break; | ||
} | ||
} | ||
|
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
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.
Are you not missing
onClosed:(ART ProtocolMessage *)message
?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.
onClosed
doesn't exist right from the beginning. I'm assuming the tests are calling theclose()
method.