websockets with Mojolicious NOT lite?

248 views
Skip to first unread message

Leslie Giles

unread,
Oct 26, 2013, 7:04:51 PM10/26/13
to mojol...@googlegroups.com
I am starting on a web project, rewriting a database web front-end.  I want the new version to use websockets, and since I know Perl well, Mojolicious looks like the way to go.  I don't want to use Mojolicious::Lite - I want a grown-up multi-file project that is good and modular and that can be easily expanded.

I can write a Mojolicious app that serves out pages, and I've written one that serves a main page that sets up a WebSocket in javascript, but for the life of me I can't work out how to write the Mojolicious::Controller.  Every single example I can find uses Mojolicious::Lite, and when I try to translate them to plain Mojolicious, they don't work.  My latest example gets as far as timing out the WebSocket connection, which I suppose is progress, but I can't get beyond this...

Yes, I've read the documentation, but it really isn't aimed at websocket-based apps.  Yes, I can write a Mojolicious application that serves out pages, and I understand the templating stuff.  I'd hate to start using something like Python, but having said that the Python tornado framework supports websockets, is simple, and includes a full working example in the CentOS package python-tornado-doc.

So please please pretty please does somebody out there have an example of a Mojolicious websocket application?  Once I have something even as simple as an echo, I should be able to move forward.

Lezz Giles

Dotan Dimet

unread,
Oct 27, 2013, 4:37:30 AM10/27/13
to mojol...@googlegroups.com
Look at Joel Berger's Galileo:
Here are his websocket routes:
https://metacpan.org/source/JBERGER/Galileo-0.030/lib/Galileo.pm#L195
$if_author->websocket( '/store/page' )->to('page#store');
($if_author is a bridge route defined earlier in the file)
And here is the action in his controller:
https://metacpan.org/source/JBERGER/Galileo-0.030/lib/Galileo/Page.pm#L43
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Leslie Giles

unread,
Oct 29, 2013, 10:28:32 AM10/29/13
to mojol...@googlegroups.com
Thanks - turns out my websockets were working after all - I didn't realize that by default the websocket times out after around 15 seconds.  If I get a good simple example with multiple persistent sockets, I'll see if I can add it to the Mojolicious wiki.

Lezz


--
You received this message because you are subscribed to a topic in the Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mojolicious/5i8Qmqok-P0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mojolicious...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages