aMSN2 is designed to offer multiple frontends so that it should be able to run on whatever you like. One such frontend is the web frontend.
The primary is not to provide you a website where you’d go and connect to MSN. Instead we want to let you host aMSN2 and run it in your web browser.
It was first designed using a webserver with php. It was working but I thought we could use directly python instead of php and embed directly a small webserver in amsn2-web.
Here is how I want to implement it, just like every other frontend:
papyon ↔ amsn2 ↔ the frontend
aMSN2 has an event loop to deal with events from papyon or the frontend. This works nicely for most of the frontends.
Here is how it was working:
There are some issues here. Having to check every X ms to know if there is something to do isn’t great. We have an event loop, let’s use it!!
First, aMSN2 should include directly the webserver and add it to it’s event loop so that when the web frontend wants something, it can reply to it right away. I’ve tried to do that with cherrypy.
I tell my browser to go to http://127.0.0.1:8080/static/amsn2.html
. After few seconds, I see in the logs that cherrypy got the query.
It’s a static file. It should handle it easily. But I wait and wait again and nothing happens. When I send SIGINT (Ctrl+c) to aMSN2, then the page load correctly!! Even in its own thread, cherrypy is blocking on something.
Here is the code I use to do that:
=
=
=
break;
return
=
=
aMSN2 should listen to 127.0.0.1:8080
(or whatever you want). When something happens, it should have a tiny HTTP machine to process the query and act just like the web frontend was like every other frontend.
Then we should use “long push”. jQuery sends a query to now what’s new. aMSN2’s doesn’t answer yet but once there is something to tell the frontend, it replies. The browser updates whatever needed based on the answer and send right away a new query to know what’s new.
If you want to help me with that, feel free to contact me.