Skip to content

WIP: Add WebSockets lib#182

Closed
forki wants to merge 33 commits into
giraffe-fsharp:masterfrom
forki:websockets
Closed

WIP: Add WebSockets lib#182
forki wants to merge 33 commits into
giraffe-fsharp:masterfrom
forki:websockets

Conversation

@forki

@forki forki commented Dec 18, 2017

Copy link
Copy Markdown
Contributor

Not sure where it belongs.

  • - discuss if it should go in separate package
  • - XML document the functions
  • - document the sockets lib in readme
  • - add tests
  • - add samples

@TheAngryByrd

TheAngryByrd commented Dec 18, 2017

Copy link
Copy Markdown
Member

Might we worth adding some tests too using TestServer like

use server = new TestServer(WebHostBuilder().Configure(fun app -> configure app))
let wsClient = server.CreateWebSocketClient()
let! websocket = wsClient.ConnectAsync(server.BaseAddress, CancellationToken.None)

@TheAngryByrd

Copy link
Copy Markdown
Member

There also might be some value comparing and contrasting this implementation with https://gist.github.com/TheAngryByrd/22b5df5a308f9f96f959980d0a42f7cd

For instance we probably should rely on WebSocketReceiveResult.EndOfMessage
in the receive part and buffer into a stream rather than hoping the message size is big enough to handle the incoming text data.

@forki

forki commented Dec 18, 2017

Copy link
Copy Markdown
Contributor Author

@TheAngryByrd please send PRs to my fork

@forki

forki commented Dec 19, 2017

Copy link
Copy Markdown
Contributor Author

@TheAngryByrd I made receive into a loop. I would appreciate some tests

@forki

forki commented Dec 22, 2017

Copy link
Copy Markdown
Contributor Author

@TheAngryByrd thanks for working with me together on this. I'm sure we can create something cool out of it.

<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.*" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.*" />

<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.0.*" />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is so dangerous. It should be pinned or converted to paket. Floating versions are such an anti pattern. Especially together with transitive deps.

@forki
forki force-pushed the websockets branch 2 times, most recently from 7249b1d to c29c294 Compare December 25, 2017 09:08
@forki forki closed this Dec 25, 2017
@forki forki reopened this Dec 25, 2017
@forki

forki commented Dec 29, 2017

Copy link
Copy Markdown
Contributor Author

@TheAngryByrd I'm now using TokenRouter to configure the server. And we have a broadcast test

@enricosada

Copy link
Copy Markdown

@enricosada

Copy link
Copy Markdown

Another good idea ihmo (found checking ws with suave in FSAC) will be implement the autobahn test suite to test the server http://websockets.github.io/ws/autobahn/servers/ to test the implementation ( link is the node ws test report ).

@forki

forki commented Dec 30, 2017

Copy link
Copy Markdown
Contributor Author

@TheAngryByrd @gerardtoconnor for some reason the tests with n=100 / 1000 are going into timeout. Any ideas why it is soooo slow?

@forki

forki commented Dec 30, 2017

Copy link
Copy Markdown
Contributor Author

ok I found the issue

@dustinmoris

Copy link
Copy Markdown
Member

Hi, I don't like letting people wait, so I've written an update on the Swagger PR and I was thinking of proposing the same here if that sounds good to you @forki ?

@forki

forki commented Feb 13, 2018

Copy link
Copy Markdown
Contributor Author

I'm fine with waiting for now.

@dustinmoris

Copy link
Copy Markdown
Member

Ok cool, just wanted to let everyone know that things are progressing every day and I'll eventually get to the bigger PRs as well. If something is urgent then there is that option of an early Alpha release.

@cotyar

cotyar commented Feb 13, 2018

Copy link
Copy Markdown

Guys,
For the ones who don't want to wait until everything is done properly I just created a branch merging both PRs together (just as a temporal solution)
https://github.com/cotyar/Giraffe/tree/SwaggerAndWebsockets
Cheers

@Banashek

Copy link
Copy Markdown
Contributor

I had created a similar implementation based on the asp docs and this blog post. I like the PR here a bit more.

One thing I noticed in the current PR state is that there is no opportunity to add behavior when a socket is closed. This is useful for updating UI when a user has left the web app. If there was perhaps an overload of onMessage where messageF was of type WebSocketReference -> string -> WebSocketMessageType -> Task<unit> it could allow patching in behavior based on the message type by the user.

@forki

forki commented Feb 26, 2018

Copy link
Copy Markdown
Contributor Author

@Banashek can you please send a pull request to my fork with your proposal? Let's work together on this to make it great

@Nhowka

Nhowka commented May 30, 2018

Copy link
Copy Markdown
Contributor

I plan to create a version of Elmish.Remoting for Giraffe. Should I wait a little more for this PR to get merged?

@cotyar

cotyar commented May 31, 2018

Copy link
Copy Markdown

No updates from Dustin for quite a while unfortunately.
And the latest version of ws breaks the previous code contract unfortunately and isn't a dropin replacement :-(

I would love to see the remoting working over WebSockets for Giraffe!

@forki

forki commented May 31, 2018

Copy link
Copy Markdown
Contributor Author

This is still WIP since I'm still trying to figure out an idiomatic way

@Nhowka

Nhowka commented May 31, 2018

Copy link
Copy Markdown
Contributor

Based on what you did until now, do you think it would be too much effort to replicate what Suave did?

@cotyar

cotyar commented May 31, 2018

Copy link
Copy Markdown

I personally use 3 months old version (without latest commits) and it does the job pretty well for me, but I'm missing onClose event. The latest one has onClose but doesn't pass the ref into onOpen (as far as I remember)

@forki

forki commented Jun 1, 2018 via email

Copy link
Copy Markdown
Contributor Author

@cotyar

cotyar commented Jun 1, 2018

Copy link
Copy Markdown

Thank you @forki , much appreciated!

Hope @dustinmoris will kindly merge it into the master and release soon together with the Swagger PR.

@coolya

coolya commented Sep 29, 2018

Copy link
Copy Markdown

I this PR dead? Haven't got any activity for three month, is there any way I can help here to get websocket support in Giraffe?

@dustinmoris

dustinmoris commented Sep 29, 2018 via email

Copy link
Copy Markdown
Member

@forki

forki commented Sep 29, 2018 via email

Copy link
Copy Markdown
Contributor Author

@dustinmoris

dustinmoris commented Sep 29, 2018 via email

Copy link
Copy Markdown
Member

@dustinmoris dustinmoris mentioned this pull request Jun 20, 2020
@forki

forki commented Jun 21, 2020

Copy link
Copy Markdown
Contributor Author

Sorry this completely wrong approach. I will come up with a new one

@forki forki closed this Jun 21, 2020
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.

10 participants