Wednesday, August 24, 2011

Multiprocess TaskServer is working

I was just about to write a blog describing how I took one step forward and took one step back.  I spent a good chunk of Saturday and today working on getting teleproc to be able to run multiple processes.  The old TaskServer class is now the Task class, and the TaskServer class is now a container of Tasks (yes, I know, I am breaking the  API, but since this isn't even an alpha, and thus the API is NOT stable, I don't have a problem with that).

Basically the TaskServer receives commands from a client, and directs those commands to a Task object.  So the client has to now specify which Task object he is interested in.  To avoid intermingling the stdout of all the processes, I am prepending all of them with a local ID.  I will rewrite the GUI client to filter each line based on the ID and strip it out.  It will then append the given line of text (from a given process) to a output area (probably a TabbedPane or something in swing or SWT).

The trick to reconnecting was that when the GUI client disconnected, the Channel object disconnected with it.  When the GUI client reconnected, a new Channel object is created by Netty.  I had to save this Channel object and set all of my Task object's readOut and readErr ThreadReader objects to use this new channel.  So I had to add some logic to do this in my ThreadReader class.

I still haven't implemented the broadcast feature yet though.  I want all clients who are connected to be able to get the same output.  I also am stoked to convert this into a clojure project.  Now that I am a little more familiar with how Netty works, I think I can use this as the basis for the networking engine for my game.  I also believe that there are a couple of areas that clojure will shine in.  For example, my parseCommand function is pretty ugly in java, and I think there's a more elegant solution I can use in clojure.

I also need to make the actual Eclipse Public License documents since that is the Open Source license I am going to use.  But the directions are really spotty.  I did find one webpage with a checklist of documents, so I will do that soon.

No comments:

Post a Comment