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

Add support for Websockets (RFC 6455) #82

Open
Kaliumhexacyanoferrat opened this issue Sep 2, 2020 · 6 comments
Open

Add support for Websockets (RFC 6455) #82

Kaliumhexacyanoferrat opened this issue Sep 2, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@Kaliumhexacyanoferrat
Copy link
Owner

As a developer of a reactive, rich client-application, I would like to use websocket connections to the webserver, so that I can easily push content from the server to the clients.

Example

Very vague - clarity comes with implementation.

class IWebsocketHandler 
{
    void Initialize(Connection connection);
    void HandleFrame(Frame frame);
}

var socket = Websocket.Create<MyHandler>();

Acceptance criteria

  • The Websocket handler is a regular IHandler that can be added where required
  • There is a separate GenHTTP.Modules.Websocket module, with a minimal hook into the server core to gain control over the socket
@Kaliumhexacyanoferrat Kaliumhexacyanoferrat added the enhancement New feature or request label Sep 2, 2020
@ToshiroZ
Copy link

ToshiroZ commented May 3, 2022

This would be quite helpful to have

@Kaliumhexacyanoferrat
Copy link
Owner Author

Websockets, along with form-based authentication, are the next topics on the agenda.

Due to my parental leave in summer, there will be few changes from my side in the next months. Pull requests or preparatory changes are of course always welcome.

@ToshiroZ
Copy link

ToshiroZ commented May 5, 2022 via email

@Kaliumhexacyanoferrat
Copy link
Owner Author

Kaliumhexacyanoferrat commented May 5, 2022

If you would like to use the Website module, you will need a theme - an empty theme should not be much effort. If you do not need the features provided by the Website, you can just render a Page in the default server theme:

var page = Page.From("My Content") // or ModScriban.Page() or ModRazor.Page() or Placeholders.Page()
               .Title("My Title")
               .Description("My description");

var layout = Layout.Create()
                   .Add("page", page); // http://localhost:8080/page

Host.Create()
    .Handler(layout)
    .Defaults()
    .Development()
    .Console()
    .Run();

Razor and Scriban allow you to render a model into a template (e.g. read from the file system).

@Kaliumhexacyanoferrat
Copy link
Owner Author

Or, if you are fine with plain text, even easier:

var handler = Inline.Create()
                    .Get("/page", () => "Hello World!");

Host.Create()
    .Handler(handler)
    .Run();

@yuexueyang
Copy link

How about the websocket module, is it ready for use?

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

No branches or pull requests

3 participants