45 lines
955 B
PHP
45 lines
955 B
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 25/feb/2016
|
|
*/
|
|
|
|
class CBS_RAPIClientImplementation extends RAPI_Client {
|
|
private $fh;
|
|
private $attachmentPath;
|
|
|
|
public function __construct($logger, $dataStorage, $attachmentPath){
|
|
parent::__construct($logger, $dataStorage);
|
|
$this->attachmentPath = $attachmentPath;
|
|
}
|
|
|
|
protected function openConnection(){
|
|
$service_port = getservbyname('rapi', 'tcp');
|
|
$address = RAPI_Config::RAPI_SERVER_ADDRESS;
|
|
$this->fh = stream_socket_client("tcp://$address:$service_port", $errno, $errstr, 30);
|
|
|
|
}
|
|
|
|
protected function closeConnection(){
|
|
fclose($this->fh);
|
|
}
|
|
|
|
protected function sendMessage($msg){
|
|
fwrite($this->fh, $msg);
|
|
}
|
|
|
|
protected function getMessage($bufferSize = null){
|
|
if (is_null($bufferSize)){
|
|
return fgets($this->fh);
|
|
}
|
|
else {
|
|
return fgets($this->fh,$bufferSize);
|
|
}
|
|
}
|
|
|
|
protected function getReceivedAttachmentPath(){
|
|
return $this->attachmentPath;
|
|
}
|
|
}
|
|
|
|
?>
|