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

Feature Request: Add out-of-the-box support for websockets #554

Open
jwoertink opened this issue Jul 27, 2018 · 10 comments · May be fixed by #1305
Open

Feature Request: Add out-of-the-box support for websockets #554

jwoertink opened this issue Jul 27, 2018 · 10 comments · May be fixed by #1305
Labels
feature request A new requested feature / option

Comments

@jwoertink
Copy link
Member

For anyone that comes looking for websocket support, you can dive in to the built in websocket support for now.

https://gitter.im/luckyframework/Lobby?at=5b5a51a61be9bb57bcc749bd

However, this is obviously something we should support out of the box with Lucky. I've never actually used websockets, so I don't know if they use HTTP methods or not, but looking at Kemal docs I would assume something like

class SomeAction < WebsocketAction
  route "/" do
    # maybe context.on_message
    # or have access to socket.on_message here?
  end
end
@citizen428
Copy link
Contributor

I don't know if they use HTTP methods or not

The WebSocket protocol is different from HTTP, but allows proxying in combination with an Upgrade: websocket header.

Having a look through Lucky::Routeable, ContextHelper, pages and friends, and keeping in mind what Rails does in ActionCable, and Phoenix with channels, I think it could look something like this:

class SomeAction < WebSocketAction
  route do 
    send_from SomeActionChannel, data: 'foo'
  end
end

This assumes the following:

  • an instance of a WebSocket "manager" of sorts that keeps track of all the subscribed sockets
  • a WebSocketAction class to mirror Action
  • A WebSocketChannel as equivalent to pages

This feels more in line with how Lucky does other stuff than the Kemal example.

@paulcsmith How do you feel about this? Interested in WS support at all?

@jwoertink jwoertink added the feature request A new requested feature / option label Jun 4, 2019
@paulcsmith
Copy link
Member

@citizen428 I think something like that sounds awesome. I think the best bet would be to have a third part shard until we figure out exactly what Channels should look like. Something like what https://github.com/cable-cr/cable. That way the community can try various things out and we can merge together the best ideas

@citizen428
Copy link
Contributor

@paulcsmith Agreed re third party shard, especially given that their README states the following:

Better integrate with Lucky, maybe with generators, or something else?

Let's try to rope in @fernandes and see if there's collaboration potential 🙂

@fernandes
Copy link
Contributor

hey @citizen428 thanks for pinging me

yeah, absolutely, cable-cr itself is just, a library heheh to be useful, it's good to be used in something like.. Lucky, for sure :)

Like actioncable, just need one route to be "mounted" at the app, it comes with a handler, that can be used as inspiration

If @jwoertink / @paulcsmith / @citizen428 wants to collaborate on lucky-cable, we create a repo on the org and you hop in there, wdyt?

@citizen428
Copy link
Contributor

citizen428 commented Oct 10, 2019

@paulcsmith Maybe we could start with you creating the lucky-cable repo for us and adding me and @fernandes as contributors to that or something?

@paulcsmith
Copy link
Member

@citizen428 good idea. I'll level it lucky-cable-preview so it is clear and invite you both. I'll also keep it private for now until you two feel it is in a state where you think people could start using it!

@paulcsmith
Copy link
Member

I spoke too soon! I can't create a private repo. @citizen428 @fernandes would one of you be ok creating a repo and adding me to it? I'd be happy to collaborate on it with reviews or answering questions. I won't have much time to write code though :(

@fernandes
Copy link
Contributor

added both you guys 😉

@paulcsmith
Copy link
Member

I'm in! Feel free to ping me or hit me up on Gitter!

@citizen428
Copy link
Contributor

Thanks @paulcsmith @fernandes

@jwoertink jwoertink linked a pull request Nov 11, 2020 that will close this issue
5 tasks
@jwoertink jwoertink added the Hacktoberfest Valid Issue for Hacktoberfest label Oct 1, 2021
@jwoertink jwoertink removed the Hacktoberfest Valid Issue for Hacktoberfest label Nov 1, 2021
@jwoertink jwoertink added the Hacktoberfest Valid Issue for Hacktoberfest label Oct 1, 2022
@jwoertink jwoertink removed the Hacktoberfest Valid Issue for Hacktoberfest label Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new requested feature / option
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants