Giter VIP home page Giter VIP logo

Comments (6)

Gazler avatar Gazler commented on July 18, 2024 2

Just to confirm on the note about Cowboy, it does automatically close the websocket if a :close reply is sent.

https://github.com/ninenines/cowboy/blob/30ee75cea14c1fd63a46093cfb2bb9ad3f844f75/src/cowboy_websocket.erl#L506

from websock_adapter.

mtrudel avatar mtrudel commented on July 18, 2024 1

Just to confirm on the note about Cowboy, it does automatically close the websocket if a :close reply is sent.

https://github.com/ninenines/cowboy/blob/30ee75cea14c1fd63a46093cfb2bb9ad3f844f75/src/cowboy_websocket.erl#L506

I just found explicit validation of this in Cowboy's documentation at the very bottom of https://ninenines.eu/docs/en/cowboy/2.6/guide/ws_handlers/

from websock_adapter.

mtrudel avatar mtrudel commented on July 18, 2024

I was just looking at phoenixframework/phoenix#5024!

I deliberately didn't accommodate sending close frames in WebSock because I didn't see a clear way to expose it, but now that the dust has settled I think I see a way forward that's really easy to land:

  • Add a clauses to t:WebSock.handle_result that looks like {:stop, reason, code | {code, message}, state}
  • Support this in WebSockAdapter.CowboyAdapter.handle_reply (I'm unclear whether Cowboy will automatically close the connection if you return a {:reply, {:close...}, state} tuple; otherwise we'd need to get fancy here with messaging ourselves or the like).
  • Support this in Bandit by adding a clause to Bandit.WebSocket.Connection.handle_continuation very much like the existing {:stop,....} tuple, making sure that the semantics are consistent with those of Cowboy
  • Document whatever those semantics are in WebSock (so long as these semantics are reasonable and consistent between implementations I'm sure they're fine).

Happy to accept PRs for this! I'd suspect it to be three PRs, one each for websock, websock_adapter, and bandit.

from websock_adapter.

mtrudel avatar mtrudel commented on July 18, 2024

This functionality is ready for review on Cowboy at the PRs linked above.

Next step is to get the websock PR reviewed & landed.

Once that's done, I'll cut a websock release and update the websock_adapter PR and Bandit PR to point at it.

from websock_adapter.

jeregrine avatar jeregrine commented on July 18, 2024

Awesome!

from websock_adapter.

mtrudel avatar mtrudel commented on July 18, 2024

All work for this is done & merged. This will now work for websock_adapter >= 0.5.0. You can update this dependency locally within any recent phoenix app & have access as needed.

from websock_adapter.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.