Yamoxic User Command Flow
This document endeavours to describe the mechanisms by which user commands flow all the way from the GUI into the bowels of Yamoxic and back again with output.
The command starts its life by being typed by the user in a chat window (See ../ChatWindow). The input line in the chat window sends a message to the ChatWindowController object, which is the file owner of the nib file ChatWindow.nib, in which the chat window GUI is contained.
ChatWindowController then continues to clear out the input line, and passes the input text as an (NSString *) to its assigned CommandController object.
The CommandController, in turn, checks whether the input line is a command or text. If it's text, it pretends it was given a "say" command, with the input text as its argument. It then instantiates CommandHandler giving it information about the correct ChatWindowController, IcecapController, and what command should be handled. The init method then transparently returns a subclass of CommandHandler which knows how to handle the relevant command.
When the CommandHandler subclass has been instantiated, it's sent a handleCommandWithArguments:(NSString *)arguments message. It then does whatever it needs to do. For the typical synchronous command, it will just do whatever it needs to do, return, and it will be released and therefore deallocated by CommandController.
For the asynchronous case, however, the CommandHandler subclass can sneakilly decide to have another class retain it. It can then store the neccessary state while it's waiting for a reply from somewhere. Also, since the command is an object, multiple methods can be involved, including callbacks. (Note: I should add convenience methods to IcecapController (probably as categories), for CommandHandler subclass callbacks.)