floreysoft is back from Google I/O
Thursday, June 11, 2009
Yesterday we returned from our trip to San Francisco where we joined the Google I/O.
As I'm suffering from Jetlag and woke up at 4 am I'll use the time where the world is still asleep to let you know what we are currently working on:
Google wave
We've been invited to join the so called "Google wave hackathon" at the Google office in Mountain View. The Google folks explained the new product and the API that developers can use to extend it.
The people at the hackathon received the first accounts on the developer preview of Google wave to play around with the API.
You can create some server side extensions (robots) and client side gadgets to add additional features.
After some experiments I figured out that it might be very useful to be able to create and test robots in the local eclipse environment instead of uploading the robot code to appengine to test the code. Also it was a little bit 80's like to not being able to debug the code right in eclipse.
Instead of complaining I've spent some hours in the hotel room and hacked on a debugging framework and finally got it working!
To develop and debug robots in your local environment you have to download this tiny jar file containing the local debugging proxy server.
You can specify a unique name for your robot when launching the jar:
java -jar wave-debugger.jar myfancyrobot
Now you can create a new wave and simply add the JDebuggy robot (jdebuggy@appspot.com) to it. This robot will add a gadget where you have to enter the same unique name to start debugging. There is a tab where you can specify exactly which events should be forwarded to you local environment. If you enable the DOCUMENT_CHANGED event you'll get events for each key you are typing so this will cause a lot of traffic and makes debugging quite hard.
You can change the settings and start and stop debugging by using the gadget and you can test your robot by using the wave as all events will be forwarded to your local environment.
If you are interested in the technical details of the implementation I'll try to explain it in a few words:
It has been a little bit tricky to get everything in place as I had to fight with several restrictions:
- If you create a robot by extending the AbstractRobotServlet the servlet input stream will be consumed by this servlet and is not accessible later on to forward it to the robot that should be debugged. So I had to create a copy of the input and output streams to be able to read it twice and send back the data of either the JDebuggy robot or the robot to be debugged. This sounds easy but the I had to write some mockup classes to fake the ServletRequest etc.
- The basic idea was to call your local servlet on your machine to trigger the robot servlet right in the eclipse environment. But your local machine is most likely not visible and reachable from the net as you may be behind a router with dynamic NAT. So I had to find a way to create the connection from your machine to a server. This could be done by polling for new events but this would make it very hard to simulate synchronous communication with the wave server. So I chose creating a open socket connection between your local machine and the server.
- Unfortunately and for good reason Google appengine will not tolerate to create threads, sockets etc. So I had to find another way to let you establish a socket connection between the two endpoints. I've created a debug proxy server on our floreysoft root server and forwarded all requests and responses from app engine to it after debugging starts. So I now could use all the dirty tricks to get it to work (server sockets, threads etc.).
The floreysoft proxy will distribute the incoming requests to the proper socket to be able to debug many robots at the same time.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home