Welcome the channel on the development of Cro, a set of libraries for building reactive distributed systems, lovingly crafted to take advantage of all the Raku Programming Language has to offer (cro.services). This channel is being logged for historical purposes. Set by lizmat on 24 May 2021. |
|||
07:33
sena_kun joined
13:57
jgaz left
15:52
Xliff joined
|
|||
Xliff | \o | 15:53 | |
Has anyone done HTTP Push pages with Cro? | |||
japhb | The only push scenarios I've needed I did with WebSockets. | 16:18 | |
16:31
jgaz joined
|
|||
Xliff | japhb++: Got any sample code? | 18:07 | |
patrickb | Is it possible to nest template parts and subs / macros? I.e. I have a fragment that requires both, page specific data (the path of the page), and common data (logged in user name, URL for login). | 19:13 | |
lizmat | patrickb: pretty sure you can | 19:14 | |
patrickb | Thanks! | 19:22 | |
japhb | Xliff: Depends on what you mean by "sample code". MUGS-Core has the pair of github.com/Raku-MUGS/MUGS-Core/blo...et.rakumod (server) and github.com/Raku-MUGS/MUGS-Core/blo...et.rakumod (client), which might help you. | 19:37 | |
But those are part of the larger MUGS-Core infrastructure, so you may find yourself a bit confused about how to use these as part of a larger whole, and I've been told that MUGS is ... kindof a lot to take in all at once. | 19:38 | ||
I guess github.com/Raku-MUGS/MUGS-Core/blo...on.rakumod gives you the quick overview of the internal Connection API; the server side of session handling starts here: github.com/Raku-MUGS/MUGS-Core/blo...kumod#L556 | 19:45 | ||
The client side of session handling is here: github.com/Raku-MUGS/MUGS-Core/blo...kumod#L170 | |||
So yeah ... not exactly set up as "sample" code, and probably more than you asked for, but it's FOSS code that actually is known to work, so there's that. ;-) | 19:48 | ||
Xliff | japhb: Exactly what I asked for. Thanks, so much! | 21:03 | |
21:04
sena_kun left
|
|||
Xliff | japhb: You are correct. It is a lot, but it isn't unmanageable, and your code is clear enough. My one question: Where is an actual implementation of .send-to-client? | 21:07 | |
japhb | Xliff: It's hooked up by github.com/Raku-MUGS/MUGS-Core/blo...es.rakumod | 21:16 | |
That's where the incoming Cro connection gets turned into a websocket session. Note that it returns the .from-server supply provided by MUGS::Server::Connection::WebSocket to Cro. Thus whenever emitting on the $!to-client Supplier, the Supply end feeds a message into the Cro WebSocket connection. :-) | 21:18 | ||
So basically the MUGS::Server::Connection::WebSocket.send-to-client just formats a Cro::WebSocket::Message and sends it into its own private Supplier, because the Supply end of that pair is already plumbed through to the client connection by Cro. :-) | 21:19 |