Gleichzeitige Ausführung von Aufrufen

Servus,

ich habe bei mir für einige Ereignisse Benachrichtigungen aktiviert, sprich es wird eine URL aufgerufen und somit auf dem Gerät was angezeigt.

Das mache ich wie folgt

if($sendToFireTV){
    @file_get_contents("http://" . $url1 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0);
    @file_get_contents("http://" . $url2 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0);
    @file_get_contents("http://" . $url3 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0);
}   

das Problem ist jetzt wenn einer der Empfänger nicht erreichbar ist das dann auf das Timeout gewartet wird.
Wie mache ich das am besten das alle 3 URLs auf einmal aufgerufen werden ?

Aus einem Script drei andere aufrufen mit jeweils einer URL.

Das wollte ich ja vermeiden 3 extra Scripte zu erstellen, sollte doch irgendwie mit Threads gehen

Bei der Anfrage nach der Suchmaschine Deines Vertrauens kommts Du ganz schnell zu pthreads (mit Beispielen!!) Ob Du damit schneller am Ziel bist, als mit den 3+1 Scripten, ist allerdings fraglich.

Grüße, Gerhard

Doku:
IPS_RunScriptText

Michael

ja genau nach sowas hatte ich gesucht
IPS_RunScriptText — IP-Symcon :: Automatisierungssoftware

aber wie übergibt man da Variabeln ?


if($sendToFireTV){
    IPS_RunScriptText('@file_get_contents("http://" . $url1 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0);');
    IPS_RunScriptText('@file_get_contents("http://" . $url2 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0);');
    IPS_RunScriptText('@file_get_contents("http://" . $url3 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0);');
}

Am besten gar nicht :slight_smile:
Sonst kommst du schnell durcheinander ob diese nun im Script oder in dem, nennen wir es Mal TextScript gültig sind, oder wann welches Hochkomma wie zu setzen ist.
Bau doch das TextScript vorher als String zusammen und lege das in eine Variable z.B. $Script.
Und dann IPS_RunScriptText($Script);
Michael

Sorry da kann ich Dir jetzt nicht folgen

ich kann ja wohl kaum


$Script = @file_get_contents("http://" . $url1 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0);  

setzen um dann
IPS_RunScriptText($Script);
aufzurufen

So?
Stimmt aber… Ist fast genau so unübersichtlich :wink: :smiley:


$Script = '@file_get_contents("http://"' . $url1 . '":7676/show?title="' . urlencode($title) . '"&msg="' . urlencode($text) . '"&position="' . $position . '"&duration="' . $duration . '"&type="' . $type . '"&transparency="' . $transparency . '"&bkgcolor="' . $bkgcolor . '"&interrupt="' . $interrupt . '"&width="' . $width .', false, NULL, 0,0);';  
IPS_RunScriptText($Script);

Michael

OK man muss auch das richtige Gerät überprüfen ob da was ankommt :smiley:
funktioniert

OK zu früh gefreut, wenn ich jetzt wieder die anderen Geräte mit rein nehmen habe ich wieder das selbe Problem mit dem TimeOut auf dem erst gewartet werden muss

    $Script = @file_get_contents("http://" . $url1 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0); 
    IPS_RunScriptText($Script);

    $Script = @file_get_contents("http://" . $url2 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0); 
    IPS_RunScriptText($Script);

    $Script = @file_get_contents("http://" . $url3 . ":7676/show?title=" . urlencode($title) . "&msg=" . urlencode($text) . "&position=" . $position . "&duration=" . $duration . "&type=" . $type . "&transparency=" . $transparency . "&bkgcolor=" . $bkgcolor . "&interrupt=" . $interrupt . "&width=" . $width . "", false, NULL, 0,0); 
    IPS_RunScriptText($Script);

So ich habe die Lösung, ich habe file_get_content in ein anderes Script ausgelagert


<?

@file_get_contents("http://" . $_IPS['url1'] . ":7676/show?title=" . urlencode($_IPS['title']) . "&msg=" . urlencode($_IPS['text']) . "&position=" . $_IPS['position'] . "&duration=" . $_IPS['duration'] . "&type=" . $_IPS['type'] . "&transparency=" . $_IPS['transparency'] . "&bkgcolor=" . $_IPS['bkgcolor'] . "&interrupt=" . $_IPS['interrupt'] . "&width=" . $_IPS['width'] . "", false, NULL, 0,0); 

?>

und rufe das dann so mittels IPS_RunScriptEx und Variabelnübergabe auf

IPS_RunScriptEx(19443 /*[FireTV-Notifications]*/, Array("url1" => "$url1", "title" => "$title", "text" => "$text", "position" => 0, "duration" => 10, "type" => 0, "transparency" => 0, "bkgcolor" => 1, "interrupt" => 0, "width" => 4));

IPS_RunScriptEx(19443 /*[FireTV-Notifications]*/, Array("url1" => "$url2", "title" => "$title", "text" => "$text", "position" => 0, "duration" => 10, "type" => 0, "transparency" => 0, "bkgcolor" => 1, "interrupt" => 0, "width" => 4));

IPS_RunScriptEx(19443 /*[FireTV-Notifications]*/, Array("url1" => "$url3", "title" => "$title", "text" => "$text", "position" => 0, "duration" => 10, "type" => 0, "transparency" => 0, "bkgcolor" => 1, "interrupt" => 0, "width" => 4));

Wichtig dabei ist das man die Variabeln „$text“ in Anführungszeichen schreibt

Auch wenn du jetzt eine fast identische Lösung, nur mit zwei Scripten hast.
Der Fehler da oben ist der gleiche wie vorher.
Du hast dort in $Script schon das Ergebnis von file_get_contents und nicht, wie in meinem Post vorher das Script als String in die Variable $Script geschrieben.

$Script = '@file_get_contents(......';

Sieht man doch schön an der Einfärbung des Textes in der Console und im Forum :wink:
Michael

Das ist schon lange nicht mehr aktuell ^^
Siehe meine Antwort direkt über Deiner

EDIT: Funktioniert alles bestens