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

Update the roster automatically when someone joins the user's current Seder #250

Closed
douglasnaphas opened this issue Nov 21, 2020 · 13 comments · Fixed by #409
Closed

Update the roster automatically when someone joins the user's current Seder #250

douglasnaphas opened this issue Nov 21, 2020 · 13 comments · Fixed by #409
Labels
websockets Uses WebSockets.

Comments

@douglasnaphas
Copy link
Owner

Use WebSockets.

@douglasnaphas
Copy link
Owner Author

Other uses of WebSockets can follow this, like pushing state changes to participants when the ringleader says everyone has joined.

@douglasnaphas
Copy link
Owner Author

douglasnaphas commented Nov 29, 2020

@douglasnaphas douglasnaphas added the websockets Uses WebSockets. label May 29, 2021
@douglasnaphas
Copy link
Owner Author

douglasnaphas commented Aug 25, 2021

TODO

  • Create a production build artifact for backend that excludes dev dependencies.
  • Does the connect handler have access to cookies? Yes. The default handler does not.
  • What happens to the response to the connect handler? Does the client get it? Could I put a pass a token from the connect handler?
  • Make a /ws-token endpoint. Authentication to the WebSocket API will require a token. It uses the same cookie as the Rest API.
  • Share the cookie-checking code between the backend HTTP handler and the WebSocket connect handler. Lambda layers? Lambda@Edge or CloudFront functions? API Gateway custom authorizer? Can those be used with WebSockets? This will be complicated by the fact that the HTTP handler uses Express's cookie-parser. The cookie logic from the HTTP handler may need to be lifted out and rewritten.

douglasnaphas added a commit that referenced this issue Aug 26, 2021
gh-250

This rename has to happen because I'm about to have additional Lambda
functions, specifically handlers for WebSocket events.
@douglasnaphas
Copy link
Owner Author

douglasnaphas commented Aug 26, 2021

Prior to my creating a production build artifact, my backend Lambda code is 25 M zipped, 128 M unzipped.

Update: It's now 8.7 M zipped, 50 M unzipped.

douglasnaphas added a commit that referenced this issue Aug 27, 2021
gh-250

I want an asset bundle for my backend Lambda source that excludes dev
dependencies, especially the tree rooted at jest, which brings in a lot
of sizable deps.
douglasnaphas added a commit that referenced this issue Aug 27, 2021
gh-250

See the parent commit to this commit for motivation.
@douglasnaphas
Copy link
Owner Author

I think WebSocket Lambda code will just live in the backend/ directory side by side with the backend Lambda code.

@douglasnaphas
Copy link
Owner Author

Helpful code sample showing the types for Lambda's event and context, and the Lambda handler return type: https://levelup.gitconnected.com/how-to-use-typescript-for-aws-lambda-in-3-steps-1996243547eb.

douglasnaphas added a commit that referenced this issue Aug 27, 2021
gh-250

I will probably not do this in prod. I want to verify that when cookies
go in a wss request:
    1. The cookie will arrive at the WS API and be logged.
    2. The cookie will or will not (not sure which) be sent along with
messages after the initial wss connection.
    3. Cross-origin WSS requests work, while cross-origin REST requests
do not.
douglasnaphas added a commit that referenced this issue Aug 27, 2021
gh-250

My last CloudFormation deployment failed with

    "Invalid request provided: AWS::CloudFront::OriginRequestPolicy"

I think I'm supposed to use cookieBehavior to tell the distro what
cookies to send, rather than including "Cookies" as a header to send.
@douglasnaphas
Copy link
Owner Author

With cookieBehavior: cloudfront.OriginRequestCookieBehavior.all(),, the connect handler receives the cookies, but the default handler does not.

@douglasnaphas
Copy link
Owner Author

douglasnaphas commented Aug 27, 2021

When I did a cross-origin WSS request to wss://d2mrfshv1ypexe.cloudfront.net/ws/, it didn't include the cookies for d2mrfshv1ypexe.cloudfront.net. This makes sense given my cookies are all SameSite=strict.

douglasnaphas added a commit that referenced this issue Mar 18, 2022
@douglasnaphas
Copy link
Owner Author

douglasnaphas commented Mar 18, 2022

TODO

  • Make a WSAPI that I can manually connect to, and see the connection handler firing
  • Connection handler: Save the Connection ID within the Room Code partition. Maybe even within the Room Code-Participant items.
  • Make it so that POSTing to the WS URL makes the POST contents show up in the roster.
  • Eliminate duplicates in the roster. No, check again should not cause the name to show up twice.
  • Are cookies sent with the disconnection request? Do I need to check them? Cookies are not received by the disconnect handler.
  • Don't send messages to disconnected clients. Have disconnect.js record a disconnect event in the room partition, and have handleJoin in stream.js consider disconnect events. I can add a test case for this.
  • Make a new user appearing in the seder in Dynamo POST to the WS URL.

@douglasnaphas
Copy link
Owner Author

@douglasnaphas
Copy link
Owner Author

douglasnaphas added a commit that referenced this issue Mar 19, 2022
douglasnaphas added a commit that referenced this issue Mar 19, 2022
gh-250

For some reason that is very hard to Google for, when I had
{window.location.origin} in the JSX that I'm changing here, it put a
comma before and after the string!
douglasnaphas added a commit that referenced this issue Mar 19, 2022
gh-250

The handlers need to authenticate the connection requests and associate
Connection IDs to Room Codes.
douglasnaphas added a commit that referenced this issue Mar 26, 2022
douglasnaphas added a commit that referenced this issue Mar 26, 2022
gh-250

I'm not finding the cookies
douglasnaphas added a commit that referenced this issue Mar 27, 2022
douglasnaphas added a commit that referenced this issue Mar 27, 2022
douglasnaphas added a commit that referenced this issue Mar 27, 2022
gh-250

I'm not giving write access for now, because I want to avoid an infinite
loop situation if I accidentally write to the db from the stream
handler.
douglasnaphas added a commit that referenced this issue Mar 27, 2022
gh-250

I can still see it there in the console, and my stream handler still
fails with a message about the endpoint.
douglasnaphas added a commit that referenced this issue Mar 27, 2022
gh-250

Incredibly, a replace() function that works from the Node REPL won't
trim wss:// from the start of my endpoint.
douglasnaphas added a commit that referenced this issue Mar 27, 2022
gh-250

Considering listeners and edge cases, it's getting too confusing for a
parent component (App) to pass a stateful WebSocket to pages.
douglasnaphas added a commit that referenced this issue Mar 28, 2022
gh-250

The first participant (the leader) was getting displayed twice.
douglasnaphas added a commit that referenced this issue Mar 29, 2022
@douglasnaphas douglasnaphas changed the title Show a pop-up when someone joins the user's current Seder Update the roster automatically when someone joins the user's current Seder Mar 30, 2022
douglasnaphas added a commit that referenced this issue Apr 9, 2022
gh-250

I don't know the room code when I get a disconnect event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
websockets Uses WebSockets.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant