private function SetConnected($Status) { $this->SetValueBoolean('Connected', $Status); $this->Connected = $Status; $this->Init(false); if ($Status === true) { IPS_RunScriptText("<?\nLSQ_RequestAllState(" . $this->InstanceID . ");"); } else { $this->_SetStop(); } // $this->RequestAllState(); }
public function ReceiveData($JSONString) { $data = json_decode($JSONString); $bufferID = $this->GetIDForIdent("BufferIN"); // Empfangs Lock setzen if (!$this->lock("bufferin")) { trigger_error("ReceiveBuffer is locked", E_USER_WARNING); return false; } // Datenstream zusammenfügen $head = GetValueString($bufferID); SetValueString($bufferID, ''); // Stream in einzelne Pakete schneiden $packet = explode(chr(0xd), $head . utf8_decode($data->Buffer)); // Rest vom Stream wieder in den Empfangsbuffer schieben $tail = array_pop($packet); SetValueString($bufferID, $tail); // Empfangs Lock aufheben $this->unlock("bufferin"); // Pakete verarbeiten $ReceiveOK = true; foreach ($packet as $part) { $part = trim($part); $Data = new LMSResponse($part); // Server Antworten hier verarbeiten if ($Data->Device == LMSResponse::isServer) { $isResponse = $this->WriteResponse($Data->Data); if ($isResponse === true) { // TODO LMS-Statusvariablen nachführen.... // continue; // später unnötig } elseif ($isResponse === false) { //Info Daten von Server verarbeiten // TODO if (!$this->DecodeLMSEvent($Data)) { } //IPS_LogMessage('LMSEvent', print_r($Data, 1)); } else { $ret = new Exception($isResponse); } } else { try { $ReceiveOK = $this->SendDataToChildren(json_encode(array("DataID" => "{CB5950B3-593C-4126-9F0F-8655A3944419}", "LMS" => $Data))); } catch (Exception $exc) { $ReceiveOK = false; trigger_error($exc->getMessage(), E_USER_NOTICE); // $ret = new Exception($exc); } if ($Data->Data[0] == LSQResponse::client) { IPS_RunScriptText("<?\nLMS_RefreshPlayerList(" . $this->InstanceID . ");"); } } } return $ReceiveOK; }