-
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
Rename payload -> data, refactor message data encoding. #171
Conversation
@@ -130,7 +129,7 @@ - (NSDictionary *)toDictionaryWithUnion:(NSArray *)items { | |||
|
|||
CCHmac(kCCHmacAlgSHA256, cKey, keyLen, cData, dataLen, hmac); | |||
NSData *mac = [[NSData alloc] initWithBytes:hmac length:sizeof(hmac)]; | |||
NSString *str = [ARTBase64PayloadEncoder toBase64:mac]; | |||
NSString *str = [mac base64EncodedStringWithOptions:0]; |
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.
What option is 0
?
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.
Sorry, I thought it was something else. Even so, can you use the enum NSDataBase64Encoding64CharacterLineLength
instead of 0
?
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.
Fixed at fb8158fbe96882208af51a935998b481084e5da0.
I did a quick look and it seems really good 👍. |
I run the tests and I got this one: ARTRealtimePresenceTest
And again, I have 2 errors related with the token initialiser: RestClient__initializer__should_accept_a_token_UsersricardopereiraRepositoriesWhitesmithablyiosablySpecRestClientswift_48, failed - Got error 'Error Domain=io.ably.cocoa Code=40100 "" UserInfo={ARTErrorStatusCode=401, NSLocalizedDescription=, NSLocalizedFailureReason=invalid credentials}'
RestClient__initializer__should_accept_a_token_UsersricardopereiraRepositoriesWhitesmithablyiosablySpecRestClientswift_48, failed - expected to eventually be nil, got <Error Domain=io.ably.cocoa Code=40100 "" UserInfo={ARTErrorStatusCode=401, NSLocalizedDescription=, NSLocalizedFailureReason=invalid credentials}>
@tcard Do you run the tests from Xcode directly or do you run them with |
45e46a2
to
fb8158f
Compare
@ricardopereira The first test is indeed my fault, I run the test suite, fixed something but then only ran it partially. Will fix later. I don't know about the other two, they are passing on my machine. It's that "invalid credentials" thing again. |
Can you check if it passes now? |
fb8158f
to
7e0be9c
Compare
@tcard I run the test and I got:
About the |
OK, that last commit finally fixed everything. There's only one test missing, "RestClient initializer should accept a token". That's weird, I run tests before pushing, but maybe I missed something on that one... I've taken a quick glance and can't figure out what is wrong with it. Anyway, that's a matter for another pull request, so I'm marking it as pending (also on the sheet). |
👍 |
@mattheworiordan PTAL |
This looks good, however I do not understand why the Cipher tests were removed. Do you plan on reintroducing the cipher tests on the fixture data later? |
@mattheworiordan I've added an issue (#181) to bring this back. I've taken a look, but I don't think I can just do this right away without changing a few things, and I'd rather focus on getting the API on shape now. |
Ok, sure |
Well, this took a bit of time to get right. It started just wanting to comply with the spec, and access message data just by doing `message.data` instead of `message.payload.payload`. So I wanted to remove just the amount of code necessary to do that, but ended up opening a can of worms and didn't stop until it kind of made sense. It seems like the whole ARTPayload business was designed with a use case which didn't really fit the spec at all, so it was then hacked here and there to kind of work in some (not all) cases by bypassing the design. It was also really overengineered, with a whole class hierarchy thingy just for a few predefined cases. I simplified the whole thing a lot and made it fit the spec. I could've just set up a custom `message.data` getter method that extracted the data from the ARTPayload instance to make it comply with the spec, but well, this would've hit us down the road anyway.
The test was expecting PresenceMessages _not_ to be decoded, which is the wrong behavior. Plus, DataEncoder has been refactored so that it doesn't take out arguments but return a custom DataEncoderOutput instance. Calling Objective-C functions with out arguments is a real pain and really unsafe. Encrypted test fixtures for presence messages are now working too.
129e16c
to
d5719b3
Compare
Rebased with no code conflicts. |
Rename payload -> data, refactor message data encoding.
RTN14d says that a transport error should be considered recoverable if it is > a network failure, a timeout such as RTN14c, or a disconnected > response, other than a token failure RTN14b) However, it does not define what it means by a "network failure", leading to each platform having to provide its own interpretation. In particular, a client recently told us that they’ve been seeing lots of OSStatus 9806 (errSSLClosedAbort) errors. This appears to indicate some sort of failure to perform an SSL handshake. We don’t understand the cause of this issue but we noticed that it was causing the client to transition to the FAILED state. Speaking to Paddy, he said that this error should be provoking a connection retry, not failure. And more broadly, he indicated that, basically, _all_ transport errors should be considered recoverable. So, that’s what we do here. He’s raised specification issue #171 for us to properly specify this and to decide if there are any nuances to consider, but is keen for us to implement this broad behaviour in ably-cocoa ASAP to help the customer experiencing the errSSLClosedAbort errors. Resolves #1817.
Well, this took a bit of time to get right. It started just
wanting to comply with the spec, and access message data just by
doing
message.data
instead ofmessage.payload.payload
. SoI wanted to remove just the amount of code necessary to do that,
but ended up opening a can of worms and didn't stop until it
kind of made sense.
It seems like the whole ARTPayload business was designed with a
use case which didn't really fit the spec at all, so it was then
hacked here and there to kind of work in some (not all) cases
by bypassing the design. It was also really overengineered, with
a whole class hierarchy thingy just for a few predefined cases.
I simplified the whole thing a lot and made it fit the spec.
I could've just set up a custom
message.data
getter method thatextracted the data from the ARTPayload instance to make it comply
with the spec, but well, this would've hit us down the road
anyway.