I think "Flexx uses tornado" was a crossing of threads (ha ha ha), I
don't think it does.

Flexx completely hides the websockets part, it's more like React (I
think, having used that once), but basically signals / listeners /
actions / reactions. It actually takes a while to understand what part
of the code's running in JS and what part in Python, seeing it's all
authored in Python.  Then you run into things like "%06x" % n not
converting n to a hex string on the JS side.  But overall the
translation from core Python to JS is quite impressive, as in so
transparent you don't even notice it.

Cheers -Terry

On Wed, Oct 31, 2018 at 10:17 AM vitalije <vitali...@gmail.com> wrote:
>>
>> Does that mean you think the flexx framework is a good idea? Or do you mean 
>> that Tornado itself would be the framework?
>
>
> I don't know about flexx. But you wrote above that flexx uses tornado for 
> websockets. I conclude from that tornado is lower level than flexx. And I 
> have implemented some websocket using tornado and it seems to me that it can 
> achieve on its own what you need for LeoWapp.
>
> For websocket to work there must be some thread which would check socket and 
> call appropriate methods/functions when websocket has been open, closed, or 
> new message has arrived. This thread should also take your outgoing messages 
> and send them to the browser. Tornado has built in IOLoop which handles all 
> threads and user doesn't have to do anything about threads except to call 
> IOLoop.start once. This is very similar like starting gui application by 
> starting mainloop.
>
> In essence web-socket programming is then very much like GUI programming. You 
> define methods that will be called when connection is established (at that 
> time one usually stores the sender address for later communication); then on 
> each received message (which is just an object of bytes type), you need to 
> decode this message (for example json.loads(msg)), and depending on decoded 
> message content perform appropriate action. This action may be to reply with 
> some value that browser has asked for, or to change something in Leo outline, 
> or to execute script and return result. For events that are generated inside 
> Leo (for example when outline needs to be redrawn) websocket handler should 
> send a message to browser informing about changes.
>
> Vitalije
>
> --
> You received this message because you are subscribed to the Google Groups 
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to leo-editor+unsubscr...@googlegroups.com.
> To post to this group, send email to leo-editor@googlegroups.com.
> Visit this group at https://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to