<?php class SocketClient { public $id; public $socket; public $handshake; function __construct($id, $socket) { $this->id = $id; $this->socket = $socket; $this->handshake = false; } function getID() { return $this->id; } function getSocket() { return $this->socket; } function write($buf) { if ($buf != "") // New messages to send // { if (is_resource($this->socket)) { socket_write($this->socket, $buf . "\r\n"); } } } // Alias for write_to() // function send($buf) { $this->write_to($buf); } function close() { return socket_close($this->socket); } function hasHandshake() { return $this->handshake == true; } } ?>