SaturnFramework / Saturn

Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
https://saturnframework.org
MIT License
708 stars 108 forks source link

How to connect to a channel? #200

Closed mastoj closed 4 years ago

mastoj commented 4 years ago

There is no sample on connecting to a channel and I struggle. I thought it would just be to send som data that looks like:

{
    "Topic": "the-topic",
    "Payload": { ... payload ... }
}

But my handler won't trigger. I do see that I manage to join.

huwmanatee commented 4 years ago

I had the same trouble, You're also missing a Ref: string field. Also depending on whether you're using the default serializer or not you might need to check the casing of the members.

Krzysztof-Cieslak commented 4 years ago

Sorry, for lack of the documentations - channels are still bit experimental, so I don't want to push into people them too hard at the moment.

As @huwmanatee mentioned, it seems the problem here is missing Ref field.

mastoj commented 4 years ago

No need to excuse yourself. I can maybe push some docs up if I ever get the time to play with it again.

On Thu, Oct 17, 2019 at 11:14 AM Krzysztof Cieślak notifications@github.com wrote:

Sorry, for lack of the documentations - channels are still bit experimental, so I don't want to push into people them too hard at the moment.

As @huwmanatee https://github.com/huwmanatee mentioned, it seems the problem here is missing Ref field.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SaturnFramework/Saturn/issues/200?email_source=notifications&email_token=AAD2NMDL44VFY4FHBB24ZWDQPAUHRA5CNFSM4IXARIGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBPM6XI#issuecomment-543084381, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD2NMEUD2L73LV4TMMHFDDQPAUHRANCNFSM4IXARIGA .

mastoj commented 4 years ago

What does the ref field do? I still struggle to get it working. Is there a good example of a fable client somewhere I can look at?

sgoguen commented 4 years ago

I was able to trigger the handler in the JavaScript console with the following:

var exampleSocket = new WebSocket("ws://localhost:8085/channel");
exampleSocket.send(JSON.stringify({ Topic: 'topic', Ref: 1, Payload: 'Test' }));

I've also added some very basic client code to channels in a feature branch here: https://github.com/sgoguen/Saturn/tree/add-channel-client-example/sample/ChannelsSample

@Krzysztof-Cieslak - What criteria do you have for closing this ticket? A Fable client?

robertpi commented 4 years ago

There's an example of using channels here as well: https://github.com/CompositionalIT/safe-sockets

Krzysztof-Cieslak commented 4 years ago

Ok, given there are some examples linked above that are working, I'll close this issue. Obviously, we still miss documentation on the topic, but hopefully, we'll be able to solve it given that I've modernized all the infrastructure about Saturn documentation.