-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add max message size #759
Add max message size #759
Conversation
|
||
// Checked after encoding, so that the client can receive callback with encoding errors | ||
if ([self exceedMaxSize:@[message]]) { | ||
ARTErrorInfo *sizeError = [ARTErrorInfo createWithCode:40009 |
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 this a common error between all libs?
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.
I think we should add those error codes in an enum or at least have it in a global&static var, even though, I know there are a bunch of hard coded codes in the source. Maybe raising an issue is appropriated. What do you think?
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.
Make sense. Issue here: #760
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.
A small comment but looks good 👍
@@ -29,6 +30,10 @@ NS_ASSUME_NONNULL_BEGIN | |||
|
|||
@property (strong, nonatomic, nullable) id data; | |||
|
|||
/// The event name, if available | |||
@property (nullable, readwrite, strong, nonatomic) NSString *name; |
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.
I don't understand why name
is moved. Is the idea to include name
in PresenceMessage
? That shouldn't happen.
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.
@paddybyers ARTBaseMessage
is a basic superclass. Given the way classes are structured now, this change allows to limit the number of implementations of the method that calculates if a bunch of messages exceeds maxMessageSize
. Yes, technically that means that an ARTPresenceMessage
can now have a name
property.
If you like, I can address this in a separate PR.
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.
So is it not easy to do:
ARTMessage.messageSize() {
return super.messageSize() + name.length;
}
?
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.
That's one way to do it. I was caught by other aspects of this PR and I didn't think of it :)
Issue here: #762
@@ -186,6 +190,16 @@ - (NSDictionary *)toJSON:(NSError *_Nullable *_Nullable)error { | |||
return self; | |||
} | |||
|
|||
- (NSString *)toJSONString { |
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.
I don't understand why this was added. We already serialised JSON message payloads didn't we?
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.
We needed a way to have a JSON-stringified representation of a dictionary, which is not a built-in function.
expect(err?.message).to(contain("maximum message length exceeded")) | ||
done() | ||
}) | ||
|
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.
Extra whitespace?
This addresses spec
TO3l8*
andRSL1i
items, aka throw an error before publishing messages when the size exceedsmaxMessageSize
.NOTE: queued messages exceeding
maxMessageSize
(RTL6d1
) will be addressed in a separate PR