86 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * Abstract class that implements the basic api for any client.
 | 
						|
 * @author jpt
 | 
						|
 * @abstract
 | 
						|
 * @package Client
 | 
						|
 */
 | 
						|
abstract class Client_AbstractClient {
 | 
						|
 | 
						|
	/**
 | 
						|
	 * @var int
 | 
						|
	 */
 | 
						|
	protected $ID;
 | 
						|
 | 
						|
	/**
 | 
						|
	 * @var string
 | 
						|
	 */
 | 
						|
	protected $group;
 | 
						|
 | 
						|
	/**
 | 
						|
	 * @var mixed Instance of Protocol_AbstractProtocolHandler
 | 
						|
	 */
 | 
						|
	protected $protocolHandler;
 | 
						|
 | 
						|
	/**
 | 
						|
	 * Contains a reference to the ClientManager in order to change stuff on the fly.
 | 
						|
	 * @var Client_ClientManager
 | 
						|
	 */
 | 
						|
	protected $clientManager;
 | 
						|
 | 
						|
	/**
 | 
						|
	 * Injects ProtocolHandler
 | 
						|
	 * @param unknown_type $protocolHandler
 | 
						|
	 * @return void
 | 
						|
	 */
 | 
						|
	public function injectProtocolHandler($protocolHandler) {
 | 
						|
		$this->protocolHandler = $protocolHandler;
 | 
						|
	}
 | 
						|
 | 
						|
	/**
 | 
						|
	 * Forwards incoming data to the ProtocolParser.
 | 
						|
	 * Calls protected processData()
 | 
						|
	 * @param string $rawData
 | 
						|
	 * @return void
 | 
						|
	 */
 | 
						|
	public function putRawData($rawData) {
 | 
						|
		$contentObject = $this->protocolHandler->parse($rawData);
 | 
						|
		$this->processContentObject($contentObject);
 | 
						|
	}
 | 
						|
 | 
						|
	/**
 | 
						|
	 * This function will be the main entry point of any client.
 | 
						|
	 * @param string $data
 | 
						|
	 * @return string
 | 
						|
	 */
 | 
						|
	abstract protected function processContentObject($contentObject);
 | 
						|
 | 
						|
	/**
 | 
						|
	 * This function will load the given config.
 | 
						|
	 * @param array $config
 | 
						|
	 */
 | 
						|
	abstract public function loadConfig($config);
 | 
						|
 | 
						|
	/**
 | 
						|
	 * @param int $id
 | 
						|
	 */
 | 
						|
	public function setID($id) {
 | 
						|
		$this->ID = $id;
 | 
						|
	}
 | 
						|
 | 
						|
	/**
 | 
						|
	 * @param string $group
 | 
						|
	 */
 | 
						|
	public function setGroup($group) {
 | 
						|
		$this->group = $group;
 | 
						|
	}
 | 
						|
 | 
						|
	/**
 | 
						|
	 * Injects ClientManager
 | 
						|
	 * @param Client_ClientManager $clientManager
 | 
						|
	 */
 | 
						|
	public function injectClientManager($clientManager) {
 | 
						|
		$this->clientManager = $clientManager;
 | 
						|
	}
 | 
						|
}
 | 
						|
?>
 |