Skip to content
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

ToJson bug #44

Closed
mattheworiordan opened this issue May 6, 2015 · 17 comments
Closed

ToJson bug #44

mattheworiordan opened this issue May 6, 2015 · 17 comments
Assignees
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@mattheworiordan
Copy link
Member

See https://github.com/ably/ably-js/blob/master/common/lib/types/presencemessage.js#L28, shouldn't this be action?

@mattheworiordan mattheworiordan added the bug Something isn't working. It's clear that this does need to be fixed. label May 6, 2015
@mattheworiordan
Copy link
Member Author

In fact, it looks like a number of supported fields are missing from the toJson and toString functions

@paddybyers
Copy link
Member

You'll see that action is already there, so the bug is that name is included.

Other fields are intentionally omitted because toJSON() is only used when sending messages, and this is the subset of fields that are sent by the client.

@paddybyers
Copy link
Member

b1632c3

@mattheworiordan
Copy link
Member Author

Thanks, but I think id is missing too and connectionId from the string representation

@paddybyers
Copy link
Member

toString() is intended to provide a useful human-readable summary containing the most relevant fields.

@mattheworiordan
Copy link
Member Author

Seems a bit arbitrary that an action enum integer value and time in milliseconds is considered useful human-readable value, but connectionId is not IMHO.

@mattheworiordan
Copy link
Member Author

Matt to remove unneeded fields such as timestamp, connectionId

@SimonWoolf SimonWoolf assigned SimonWoolf and unassigned paddybyers Sep 2, 2015
@SimonWoolf
Copy link
Member

Is the action here to remove the timestamp & connectionId fields from the presencemessage object entirely?

@mattheworiordan
Copy link
Member Author

Is the action here to remove the timestamp & connectionId fields from the presencemessage object entirely?

Yes, plus if clientId matches the authenticated clientId, or if clientId is empty, then we don't need to send that field.

@SimonWoolf
Copy link
Member

I don't see how that can be right. We use the timestamp and connectionId in the presence message to decide whether incoming presence messages should supersede presenceMap items with the same clientId + connectionId: https://github.com/ably/ably-js/blob/master/common/lib/client/realtimepresence.js#L256:L261. If we're removing those two from the object entirely (not just from the fromJSON() and toString() calls), then that problem'll be unsolved

@SimonWoolf
Copy link
Member

PR that only changes the json/string rep: #117

@paddybyers
Copy link
Member

timestamp is server-assigned, not client-assigned, so doesn't need to be sent by the client.

connectionIdis implicit on a realtime connection, so also doesn't need to be sent by the client. Since the client never sends PresenceMessages via REST, then there is no need to include it. Messages are of course different in that respect.

@mattheworiordan
Copy link
Member Author

@paddybyers and you agree that clientId is not needed unless the client is not authenticated yes?

@paddybyers
Copy link
Member

you agree that clientId is not needed unless the client is not authenticated yes?

It's correct that if a clientId is set on the library then it doesn't need to be populated in each Message. That's a different matter however from whether or not it needs to be supported in toJSON().

@mattheworiordan
Copy link
Member Author

@paddybyers well perhaps, but then the client library somewhere needs to move clientId if the user explicitly sets it. Also, from what I can see, I think we'll by default always be sending clientId with a null value which also is unnecessary?

@paddybyers
Copy link
Member

the client library somewhere needs to move clientId if the user explicitly sets it.

it doesn't do that yet. But that's not in toJSON().

I think we'll by default always be sending clientId with a null value which also is unnecessary?

If unset it will be undefined, and therefore will not be in the encoded result.

This toJSON() would not be here if it wasn't for the need to base64-encode binary data. If an undefined member is present to begin with, it's fine for that same member to be present with undefined value in the result.

@mattheworiordan
Copy link
Member Author

Ok, makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

3 participants