Skip to content

Discussion for WebSockets extension syntax #619

@benpate

Description

@benpate

We're moving WebSockets support into an extension (so it was decreed by @1cg). This thread is to collect suggestions/feedback on the syntax that we use in the new code. I'm going to start on this after I work out SSEs (#618), so please let me know if I'm missing anything, or if there's something we should add. Now is the time :)

I would like to keep it as close to the existing syntax as possible, but there are some funny things with the existing code, so now might be our chance to normalize it a little.

Questions:

  1. Do we want to keep the swap-oob syntax for received messages? Or is there another way to target DIVs that might be better? This would be cool, but I don't think the WebSocket protocol gives us anything standard to work with. Would love to get input from someone using the current hx-ws tag.

  2. Is there a better / more convenient way to send messages? I'm going to propose multiple encoding options for this data, including JSON (the current encoding), URL encoded, and multipart FormData.

Here's my first pass:

<div hx-ext="websocket" ws-connect="/my-websocket-address">
    <form ws-send="json | url | form ">
        <input name="message"/>
    </form>
</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions