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

More docs about extending #197

Merged
merged 5 commits into from
Dec 18, 2023

Conversation

fonsp
Copy link
Contributor

@fonsp fonsp commented Nov 22, 2023

Hey! Did I understand the extension system correctly? I made updates to the docs with the things I learned, but please correct the mistakes

Questions:

  1. Where is the right place to do something like start an HTTP server?
  2. How do I use my new connection type? How do I get the Session object?
  3. Do you let multiple clients connect to the same JSServe.FrontendConnection? To the same WebSocket? Or do you create a new JSServe.FrontendConnection for each client?
  • If you let multiple clients connect to the same JSServe.FrontendConnection, should Base.write(::MyConnection write to all connected clients?

@fonsp
Copy link
Contributor Author

fonsp commented Nov 22, 2023

Can you also take a look at JuliaWeb/Hyperscript.jl#43 ? Would be sad to leave the cool package unmaintained 😢

if i_want_to_use_it
# TODO: should I create a new session myself?
session = Session()
return MyConnection(session)
Copy link
Owner

Choose a reason for hiding this comment

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

You don't need to create a session here, this will get created automatically! A connection is not in control of a session, instead a Session creates a connection to communicate.

@SimonDanisch
Copy link
Owner

SimonDanisch commented Nov 22, 2023

Thank you! : )

  1. it's either in setup_connection or as I do it for Websocket connection in the connection constructor: https://github.com/SimonDanisch/JSServe.jl/blob/master/src/connection/websocket.jl#L13-L15 (it creates a singleton server).
  2. You shouldn't really need those. After registering your connection as the default in a certain situation, that connection type will always be used for a new session. So for e.g. Pluto, it's when Pluto is loaded: https://github.com/SimonDanisch/JSServe.jl/blob/master/src/registry.jl#L207-L210.
  3. A session encapsulates the connection to a single client. For notebooks we do have subsessions and subconnections, that communicate via one global session and allow to still create a session for each cell (for better cleanup of the used resources).

edit: you do get the Session in setup_connection(session::Session{MyConnection}), and it gets called whenever a connection is created with your Connection type

@SimonDanisch SimonDanisch merged commit 0cf6ce0 into SimonDanisch:master Dec 18, 2023
3 checks passed
@fonsp fonsp deleted the extending-docs-extra-text branch December 19, 2023 10:31
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.

2 participants