====== Developer guidelines for pfc-2.0 ====== {{http://img530.imageshack.us/img530/4250/pfc2classesih4.png}} ===== phpFreeChat PHP classes roles ===== ==== phpFreeChat_Server ==== Abstract class factory which creates the concrete ''phpFreeChat_Server'' objects. Examples: IRC, XMPP, File ... It also factorizes a static reference to the current ''phpFreeChat'' instance. The concretes ''phpFreeChat_Server'' classes roles are to provide the glue between phpfreechat and the server's specificities. ==== phpFreeChat_Server_IRC ==== Handles the network communications between phpfreechat and the real IRC server somewhere on the Internet. * It creates a socket to connect to the IRC server thanks to the host and port parameters. * It receives raw data from the IRC server, creates the corresponding phpfreechat commands (''phpFreeChat_Command_IRC'') and pushes it to the corresponding command queue (''phpFreeChat_CommandQueue_Server2Client''). * It forwards the incoming phpfreechat commands to the network socket through the network socket. ==== phpFreeChat_Client ==== Abstract class factory which creates the concrete ''phpFreeChat_Client'' objects. Currently, the only available client is ''Web'' but we can imagine other kind of clients in the future. It also factorizes a static reference to the current ''phpFreeChat'' instance. The concretes ''phpFreeChat_Client'' classes roles are to provide the glue between phpfreechat and the client's specificities. ==== phpFreeChat_Client_Web ==== Handles the network communications between phpfreechat and the web client. * It pops the server response commands from the ''Server2Client'' queue and send it to the browser using the JSON format. * It reads the JSON encoded browser commands and pushes it to the ''Client2Server'' queue. ==== phpFreeChat_CommandQueue ==== It is a queue that contains the phpfreechat commands. Commands in the queue are ordered with simple priorities: 0 for low, 1 for medium, 2 for high and 3 for critical. ''phpFreeChat'' instance manage two queue instances: ''Server2Client'' and ''Client2Server''. $command1 = phpFreeChat_Command::factory('IRC','PING'); $command2 = phpFreeChat_Command::factory('IRC','JOIN #pfc'); $queue = new phpFreeChat_CommandQueue_Client2Server(); $queue->push($command1); // medium priority command (default) $queue->push($command2, 3); // critical priority command $o1 = $queue->pop(); // $o1 contains $command2 $o2 = $queue->pop(); // $o2 contains $command1 ==== phpFreeChat_CommandQueue_Server2Client ==== This queue is used to store commands coming from the ''phpFreeChat_Server_...'' instance and for the ''phpFreeChat_Client_...'' instance. ==== phpFreeChat_CommandQueue_Client2Server ==== This queue is used to store commands coming from the ''phpFreeChat_Client_...'' instance and for the ''phpFreeChat_Server_...'' instance. ==== phpFreeChat_Command ==== Abstract class factory used to create concrete ''phpFreeChat_Command_...'' objects. Examples: IRC, XMPP, File ... It also factorizes a static reference to the current ''phpFreeChat'' instance. $command = phpFreeChat_Command::factory('IRC','JOIN #pfc'); The command creation process will automatically link wanted command proxies (described in the global parameters) to the given command. ==== phpFreeChat_Command_IRC ==== Abstract class factory used to create concrete ''phpFreeChat_Command_IRC...'' commands. Examples: PING, PONG, PRIVMSG, JOIN ... $command = phpFreeChat_Command_IRC::factory('JOIN #pfc'); ==== phpFreeChat_Command_IRC_JOIN ==== Implements the JOIN command for the IRC protocol on phpfreechat. $command = new phpFreeChat_Command_IRC_JOIN('#pfc'); ==== phpFreeChat_Command_Proxy ==== Abstract class factory used to create concrete ''phpFreeChat_Command_Proxy...'' objects. Examples: Log, CountUser, ... $logproxy = phpFreeChat_Command_Proxy::factory('IRC','Log'); ... $countproxy = phpFreeChat_Command_Proxy::factory('IRC','CountProxy'); ==== phpFreeChat_Command_Proxy_Log ==== A concrete command proxy that will log the chat communications into a given container (File, BDD ...) ==== phpFreeChat_Command_Proxy_Log_IRC ==== This command proxy is inherited from the Log proxy. It provide the same role as the parent Log proxy but adapted to the IRC driver. This class will contains IRC specific code to reformat the IRC communications to a generic format excepted by the Log proxy.