Re: Example of real world use?

89 views
Skip to first unread message

Alexander Gödde

unread,
Jul 21, 2014, 4:09:38 PM7/21/14
to autob...@googlegroups.com
Hi! 

I guess what you're referring to is that in the demos the logic is contained inside the onOpen handler. This is purely to make things more concise.
With a globally accessible session object, you can make WAMP calls, subscriptions, publishes and registers at any time in your code. All you need to make sure is that this is executed after session establishment or has error handling. 

As for more complex examples: There are some for Crossbar.io (http://crossbar.io), a WAMP router. So far, AFAIK, none of them rely on more than basic WAMP functionality of the router, so you could adapt these for use with e.g. the basic router included in Autobahn|Python. (You could, of course, also just use Crossbar.io for your routing - it's open source and new features are added all the time.)

Something simple there is the chat demo (https://github.com/crossbario/crossbardemo/blob/master/web/demo/chat/js/chat.js) (no guarantee for code quality - I wrote this when I was starting out in Web development myself). 

Hope this helps!

Alex


2014-07-21 19:59 GMT+02:00 Joris Stork <joris...@gmail.com>:
If I understand Autobahn correctly, it provides an nice library across many languages to leverage things like WAMP and WebSockets to perform duplex near real time communication (messages and/or rpcs) between applications (including browsers) across networks.

This sounds great and I'd like to use it! I have an existing, rather complex Python application that occasionally (a few times per second) needs to send and receive data (small amounts of json) to/from another python application on another host.

As a scientific programmer with very minimal web programming experience (1 day's experience with twisted and tornado), I would really like an example of how I can leverage autobahn to send and receive data *from my existing application*.

But all the examples on autobahn.ws have all their logic inside the functions/callbacks defined in the protocol, and I cannot find any examples of using Autobahn to do my kind of task: send my data every so often over a publish/subscribe pattern.

Am I completely missing the point or are these kinds of examples still in the making?

Regards

Joris

--
You received this message because you are subscribed to the Google Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to autob...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/650770e3-1380-438b-a59c-438cea8c9039%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tobias Oberstein

unread,
Jul 21, 2014, 4:18:29 PM7/21/14
to autobahnws

Have a look at this:
https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/app/crochet/README.md

Crochet allows you to use Twisted libraries like Autobahn from plain Python (blocking, synchronous, threaded)

What libs / kind of Python programs do you use /do?

Sent from Mobile (Google Nexus 5)

Joris

unread,
Jul 22, 2014, 4:41:30 AM7/22/14
to autob...@googlegroups.com
Thank you for your tips, Alexander and Tobias. I will first try to use the globally accessible session object (to avoid resorting to an extra library), and if that doesn't work out I'll try the Crotchet approach. If the latter happens I might ask whether there is an equivalent approach based on asyncio! But hopefully the global-session-object is workable.

To answer your question Tobias: I build computer vision software and still use python 2.7 (pending the release of OpenCV 3.0). Numpy is my bread and butter. I'm interested in web sockets and wamp because of the browser support which might come in handy later, and also because of the libraries on eg iOS. Otherwise I would have just gone the sockets route.

regards - joris

Joris

unread,
Jul 22, 2014, 4:49:42 AM7/22/14
to autob...@googlegroups.com

Joris

unread,
Jul 22, 2014, 5:10:09 AM7/22/14
to autob...@googlegroups.com, alexande...@googlemail.com
As a modestly experienced python programmer and having spent a little more than a day on the docs and examples, I would like to give some early feedback:

- the idea of autobahn is fantastic
- there's obviously quality thinking and lots of energy going into development and support, which is a big draw
- the API, doc and coding conventions (in python at least) are very difficult to navigate -- this seems to be at least partly inherited from Twisted. Python inspires me to write elegant code, but the little bit of autobahn/twisted I've tried blows my style to smithereens!

Tobias Oberstein

unread,
Jul 23, 2014, 11:28:51 AM7/23/14
to autob...@googlegroups.com
Am 22.07.2014 10:41, schrieb Joris:
> Thank you for your tips, Alexander and Tobias. I will first try to use
> the globally accessible session object (to avoid resorting to an extra

Yes, that is the most comfortable way. Note that this will only work if
_all_ your code is non-blocking.

> library), and if that doesn't work out I'll try the Crotchet approach.

This option is useful if your app is blocking code, and you don't want
to rewrite that to non-blocking.

> If the latter happens I might ask whether there is an equivalent
> approach based on asyncio! But hopefully the global-session-object is
> workable.

Session object somewhere on your app object: sure.

Crochet for asyncio: not that I know of ..

>
> To answer your question Tobias: I build computer vision software and
> still use python 2.7 (pending the release of OpenCV 3.0). Numpy is my
> bread and butter. I'm interested in web sockets and wamp because of the

So you are actually implementing computer vision algos in Numpy? Cool.

> browser support which might come in handy later, and also because of the
> libraries on eg iOS. Otherwise I would have just gone the sockets route.

Ah, I see. Yep, using WebSocket and WAMP you could hook up HTML5, WebGL
or native iOS clients using the same protocol and comms.

>
> regards - joris
>
>
> On Monday, July 21, 2014 10:18:29 PM UTC+2, Tobias Oberstein wrote:
>
> Have a look at this:
> https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/app/crochet/README.md
> <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/app/crochet/README.md>
>
> Crochet allows you to use Twisted libraries like Autobahn from plain
> Python (blocking, synchronous, threaded)
>
> What libs / kind of Python programs do you use /do?
>
> Sent from Mobile (Google Nexus 5)
>
> Am 21.07.2014 19:59 schrieb "Joris Stork" <joris...@gmail.com
> <javascript:>>:
>
> If I understand Autobahn correctly, it provides an nice library
> across many languages to leverage things like WAMP and
> WebSockets to perform duplex near real time communication
> (messages and/or rpcs) between applications (including browsers)
> across networks.
>
> This sounds great and I'd like to use it! I have an existing,
> rather complex Python application that occasionally (a few times
> per second) needs to send and receive data (small amounts of
> json) to/from another python application on another host.
>
> As a scientific programmer with very minimal web programming
> experience (1 day's experience with twisted and tornado), I
> would really like an example of how I can leverage autobahn to
> send and receive data *from my existing application*.
>
> But all the examples on autobahn.ws <http://autobahn.ws> have
> all their logic inside the functions/callbacks defined in the
> protocol, and I cannot find any examples of using Autobahn to do
> my kind of task: send my data every so often over a
> publish/subscribe pattern.
>
> Am I completely missing the point or are these kinds of examples
> still in the making?
>
> Regards
>
> Joris
>
> --
> You received this message because you are subscribed to the
> Google Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to autobahnws+...@googlegroups.com <javascript:>.
> To post to this group, send email to autob...@googlegroups.com
> <javascript:>.
> <https://groups.google.com/d/msgid/autobahnws/650770e3-1380-438b-a59c-438cea8c9039%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com
> <mailto:autobahnws+...@googlegroups.com>.
> To post to this group, send email to autob...@googlegroups.com
> <mailto:autob...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autobahnws/b6e06301-5329-496c-9315-3cfcf9229deb%40googlegroups.com
> <https://groups.google.com/d/msgid/autobahnws/b6e06301-5329-496c-9315-3cfcf9229deb%40googlegroups.com?utm_medium=email&utm_source=footer>.

Tobias Oberstein

unread,
Jul 23, 2014, 11:34:30 AM7/23/14
to autob...@googlegroups.com, alexande...@googlemail.com
Am 22.07.2014 11:10, schrieb Joris:
> As a modestly experienced python programmer and having spent a little
> more than a day on the docs and examples, I would like to give some
> early feedback:
>
> - the idea of autobahn is fantastic
> - there's obviously quality thinking and lots of energy going into
> development and support, which is a big draw
> - the API, doc and coding conventions (in python at least) are very
> difficult to navigate -- this seems to be at least partly inherited from

Absolutely. The docs definitely could be better.

> Twisted. Python inspires me to write elegant code, but the little bit of
> autobahn/twisted I've tried blows my style to smithereens!

Mmh. Could you elaborate? E.g. with this code

https://github.com/tavendo/AutobahnPython#show-me-some-code

What is hard to understand or "non-elegant"?

>
> On Monday, July 21, 2014 10:09:38 PM UTC+2, Alexander Gödde wrote:
>
> Hi!
>
> I guess what you're referring to is that in the demos the logic is
> contained inside the onOpen handler. This is purely to make things
> more concise.
> With a globally accessible session object, you can make WAMP calls,
> subscriptions, publishes and registers at any time in your code. All
> you need to make sure is that this is executed after session
> establishment or has error handling.
>
> As for more complex examples: There are some for Crossbar.io
> (http://crossbar.io), a WAMP router. So far, AFAIK, none of them
> rely on more than basic WAMP functionality of the router, so you
> could adapt these for use with e.g. the basic router included in
> Autobahn|Python. (You could, of course, also just use Crossbar.io
> for your routing - it's open source and new features are added all
> the time.)
>
> Something simple there is the chat demo
> (https://github.com/crossbario/crossbardemo/blob/master/web/demo/chat/js/chat.js
> <https://github.com/crossbario/crossbardemo/blob/master/web/demo/chat/js/chat.js>)
> (no guarantee for code quality - I wrote this when I was starting
> out in Web development myself).
>
> Hope this helps!
>
> Alex
>
>
> 2014-07-21 19:59 GMT+02:00 Joris Stork <joris...@gmail.com
> <javascript:>>:
>
> If I understand Autobahn correctly, it provides an nice library
> across many languages to leverage things like WAMP and
> WebSockets to perform duplex near real time communication
> (messages and/or rpcs) between applications (including browsers)
> across networks.
>
> This sounds great and I'd like to use it! I have an existing,
> rather complex Python application that occasionally (a few times
> per second) needs to send and receive data (small amounts of
> json) to/from another python application on another host.
>
> As a scientific programmer with very minimal web programming
> experience (1 day's experience with twisted and tornado), I
> would really like an example of how I can leverage autobahn to
> send and receive data *from my existing application*.
>
> But all the examples on autobahn.ws <http://autobahn.ws> have
> all their logic inside the functions/callbacks defined in the
> protocol, and I cannot find any examples of using Autobahn to do
> my kind of task: send my data every so often over a
> publish/subscribe pattern.
>
> Am I completely missing the point or are these kinds of examples
> still in the making?
>
> Regards
>
> Joris
>
> --
> You received this message because you are subscribed to the
> Google Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to autobahnws+...@googlegroups.com <javascript:>.
> To post to this group, send email to autob...@googlegroups.com
> <javascript:>.
> <https://groups.google.com/d/msgid/autobahnws/650770e3-1380-438b-a59c-438cea8c9039%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com
> <mailto:autobahnws+...@googlegroups.com>.
> To post to this group, send email to autob...@googlegroups.com
> <mailto:autob...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autobahnws/815a5c42-340b-4bac-a521-157bca762ecd%40googlegroups.com
> <https://groups.google.com/d/msgid/autobahnws/815a5c42-340b-4bac-a521-157bca762ecd%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages