Exemple #1
0
 public function testServerHandler()
 {
     // Create fs mock
     $fs = $this->getMockBuilder('\\samsonphp\\fs\\FileService')->disableOriginalConstructor()->getMock();
     $serverHandler = new ServerHandler($fs);
     $serverHandler->name();
     $serverHandler->size();
     $serverHandler->file();
     $serverHandler->type();
     $serverHandler->write('fileName', 'fileDir', 'uploadDir');
 }
 /**
  * Handle client data
  *
  * @param   peer.Socket socket
  * @return  var
  */
 public function handleData($socket)
 {
     // Check if socket on eof
     if (NULL === ($bytes = $this->readBytes($socket, 12))) {
         return;
     }
     $header = unpack('Nmagic/cvmajor/cvminor/ctype/ctran/Nlength', $bytes);
     if (0x3c872747 != $header['magic']) {
         $this->answer($socket, 0x7, 'Magic number mismatch');
         return NULL;
     }
     $impl = new ServerHandler();
     $impl->setSerializer($this->serializer);
     return $impl->handle($socket, $this, $header['type'], $this->readBytes($socket, $header['length']));
 }