Skip to content
Permalink
Browse files

Merge pull request #322 from tarasfrompir/master

Update Core.php
  • Loading branch information...
T-REX-XP committed Oct 3, 2018
2 parents 30751f2 + cb0c665 commit e2a2cb980fc5d4bddce448de840fbe47e7120f52
Showing with 10 additions and 5 deletions.
  1. +10 −5 modules/ssdp_finder/upnp/vendor/jalder/upnp/src/Core.php
@@ -49,7 +49,7 @@ public function search($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from
}
public function search_3rddevice($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from = null, $port = null, $sockTimout = '2')
public function search_3rddevice($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from = null, $port = null, $sockTimout = '5')
{
$response = array();
//create the socket
@@ -87,7 +87,7 @@ public function search_3rddevice($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discove
socket_sendto($socket, $request, strlen($request), 0, '255.255.255.255', 1900);
// send the data from socket
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>$sockTimout, 'usec'=>'128'));
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>$sockTimout, 'usec'=>'500'));
do {
$buf = null;
@@ -127,20 +127,25 @@ public function search_3rddevice($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discove
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1);
socket_bind($sock, 0, 6777);
socket_sendto($sock, $post_data, strlen($post_data) , 0, '239.255.255.250', 6000);
socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array( "sec" => 2, "usec" => 128));
socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array( 'sec'=>$sockTimout, 'usec'=>'500'));
do
{
$buf = null;
@socket_recvfrom($sock, $buf, 1024, 0, $host, $sport);
if (!is_null($buf))
{
if (strstr($buf, '"msgType":"Info"')) {
//если это МАГ 250 и емы подобные то парсим этим путем
$data = $this->parsemag250($buf, $host);
$response[$data['usn']] = $data;
}
} else {
// остальные ответы от всехустройств
$response[$data['usn']] = $buf;
}
}
}
while (!is_null($buf));
socket_close($socket);
return $response;
}

0 comments on commit e2a2cb9

Please sign in to comment.
You can’t perform that action at this time.