addServer(); $gearClient->doBackground( 'Broadcast', json_encode($data) ); /*$cmd = \Zend\Json\Json::encode(array(array( 'cmd' => $command, 'params' => array( 'password' => 'ap3dP2ssk3Y', 'pubid' => $pubid, 'raw' => $raw, 'channel' => $channel, 'data' => $data ) ))); try { if (false && function_exists('curl_init')) { #-> Have curl, use it. $ch = curl_init('http://127.0.0.1:6969'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $cmd); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($cmd)) ); $result = curl_exec($ch); curl_close($ch); return \Zend\Json\Json::decode($result); } else { #-> No curl, use the slower option. $result = @file_get_contents('http://127.0.0.1:6969', null, stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/json' . "\r\n" . 'Content-Length: ' . strlen($cmd) . "\r\n", 'content' => $cmd ) ))); return \Zend\Json\Json::decode($result); } } catch (\Exception $e) { error_log(__CLASS__ . " >> $e"); return false; }*/ } /** * Broadcast a Dataset Refresh notification. * @param string $datasetName * @return array|boolean */ static public function broadcastBuildDatasetChange($datasetName) { return self::broadcast('synchv1', array( 'Meta' => array( 'Strategy' => 'Build', 'DatasetName' => $datasetName, 'Type' => self::CHANGE_TYPE_REFRESH ), 'Data' => array() )); } /** * Broadcast a Dataset Update notification. * @param string $datasetName * @param string $changeType * @param array $datasetRecord * @return array|boolean */ static public function broadcastUpdateDatasetChange($datasetName, $changeType, array $datasetRecord) { return self::broadcast('synchv1', array( 'Meta' => array( 'Strategy' => 'Update', 'DatasetName' => $datasetName, 'Type' => $changeType ), 'Data' => $datasetRecord )); } }