GameClient.class.inc

phudbase/server/includes/classes/Server/GameClient.class.inc · 902 B

From the archive phudbase-1.11.tar.gz

Download the archive   « Back to the archive contents

<?php
class GameClient extends SocketClient
{
	private $characterEID; // Unique ID of character in game engine //
	private $lastInput;
	
	private $clientType = GC_TELNET; // Telnet, WebSocket or Flash //
	
	function setCharEID($eid)
	{
		$this->characterEID = $eid;		
	}
	
	function getCharEID()
	{
		return $this->characterEID;
	}
	
	function setClientType($type)
	{
		$this->clientType = $type;
	}
	
	function getClientType()
	{
		return $this->clientType;
	}
	
	function getLastTime()
	{
		return $this->lastInput;
	}
	
	function setLastTime()
	{
		$this->lastInput = microtime(true);
	}
	
	function send($buf)
	{
		if ($buf != "") // New messages to send //
	    {
			if (is_resource($this->socket)) 
			{
				if ($this->clientType != GC_WEBSOCKET)
		        	socket_write($this->socket, $buf . "\r\n");
				else
					socket_write($this->socket, chr(0) . $buf . chr(255));
		    }			
	    }
	}
}
?>

Site Stats

Snippets: 1791
Codebases: 571