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

feat: add client socket ID to LiveQuery ws_disconnect, ws_connect , connect and subscribe event #7999

Open
wants to merge 8 commits into
base: alpha
Choose a base branch
from

Conversation

krtooch
Copy link

@krtooch krtooch commented May 12, 2022

New Pull Request Checklist

Issue Description

In order to create a Online/offline functionality with ParseLiveQuery socket protocol, i'd like to add client's socket Id to 'ws_disconnect' event, in order to know which socket is disconnecting.

Approach

Just add existing client ID, to ws_disconnect Object.

TODOs before merging

  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • A changelog entry is created automatically using the pull request title (do not manually add a changelog entry)

This is my first ever contribution on Github, so sorry if not totally well done.

@parse-github-assistant
Copy link

parse-github-assistant bot commented May 12, 2022

Thanks for opening this pull request!

  • ❌ Please link an issue that describes the reason for this pull request, otherwise your pull request will be closed. Make sure to write it as Related issue: #123 in the PR description, so I can recognize it.

@krtooch krtooch changed the title feat : (ParseLiveQuery) add client socket on 'ws_disconnect' feat : ParseLiveQuery - add client socket Id on ws_disconnect May 12, 2022
@krtooch krtooch changed the title feat : ParseLiveQuery - add client socket Id on ws_disconnect feat : (ParseLiveQuery) add client socket Id on ws_disconnect May 12, 2022
@krtooch krtooch changed the title feat : (ParseLiveQuery) add client socket Id on ws_disconnect feat : (ParseLiveQuery) add client socket Id on ws_disconnect May 12, 2022
@krtooch krtooch changed the title feat : (ParseLiveQuery) add client socket Id on ws_disconnect feat : add client socket id on ws_disconnect event May 12, 2022
@krtooch krtooch changed the title feat : add client socket id on ws_disconnect event feat: (ParseLiveQuery) add client socket id on ws_disconnect event May 12, 2022
@mtrezza mtrezza changed the title feat: (ParseLiveQuery) add client socket id on ws_disconnect event feat: add client socket ID to LiveQuery ws_disconnect event May 12, 2022
@mtrezza mtrezza linked an issue May 12, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #7999 (20445b8) into alpha (b10182f) will increase coverage by 0.00%.
The diff coverage is n/a.

❗ Current head 20445b8 differs from pull request most recent head deeff1f. Consider uploading reports for the commit deeff1f to get more accurate results

@@           Coverage Diff           @@
##            alpha    #7999   +/-   ##
=======================================
  Coverage   94.11%   94.11%           
=======================================
  Files         182      182           
  Lines       13621    13621           
=======================================
+ Hits        12819    12820    +1     
+ Misses        802      801    -1     
Impacted Files Coverage Δ
src/LiveQuery/ParseLiveQueryServer.js 95.48% <ø> (ø)
src/RestWrite.js 94.46% <0.00%> (+0.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b10182f...deeff1f. Read the comment docs.

@mtrezza
Copy link
Member

mtrezza commented May 12, 2022

@krtooch thanks for the PR, let us know when this is ready for review.

@krtooch
Copy link
Author

krtooch commented May 13, 2022

ok for review.

@mtrezza mtrezza requested a review from a team May 13, 2022 13:51
Copy link
Member

@dblythy dblythy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and for taking this change into your own hands!!

I think it is expected that all onLiveQueryEvent triggers will work the same. I have noticed no other events have clientId. I am all for adding clientId but I think it should be added to ws_connect and the other events.

if (event === 'ws_disconnect') {
Parse.Cloud._removeAllHooks();
expect(sessionToken).toBeDefined();
expect(clientId).toBeDefined();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness can we add tests for the other keys in req (e.g req.masterKey)

@krtooch
Copy link
Author

krtooch commented May 16, 2022

Hello i added clientId, to ws_connect , connect and subscribe, and add some test to check req.

@krtooch krtooch changed the title feat: add client socket ID to LiveQuery ws_disconnect event feat: add client socket ID to LiveQuery ws_disconnect, ws_connect , connect and subscribe event May 16, 2022
Copy link
Member

@dblythy dblythy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

expect(useMasterKey).toBeDefined();
expect(installationId).toBeDefined();
}
if (event === 'subscribe') {
Copy link
Member

@mtrezza mtrezza May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split this up into individual tests for each event? Bulk tests have shown to be more difficult to maintain, also the test description would not be accurate anymore: "access user on onLiveQueryEvent disconnect".

@mtrezza
Copy link
Member

mtrezza commented May 30, 2022

@krtooch Could you address any open review comments, so we can merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add client socket ID to LiveQuery 'ws_disconnect' event
3 participants