Skip to content

Instantly share code, notes, and snippets.

@Gabrielr47
Last active July 3, 2017 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gabrielr47/23fd7e402ad9e56812f5ec7816d2f40c to your computer and use it in GitHub Desktop.
Save Gabrielr47/23fd7e402ad9e56812f5ec7816d2f40c to your computer and use it in GitHub Desktop.
processo em paralelo usando soap e ob_start
<?php
class Negociacao{
public $id = '';
/*
Retorna código de rastreio das condições do usuário.
*/
public function SolicitarOpcoesPagamento($cpfOuCnpj, $telefone, $email, $nrParcelas, $dataPagamento){
$codigo = md5($cpfOuCnpj);
file_put_contents("solicitar.txt", date('d/m/Y H:i:s') . " id: " . $codigo);
return $codigo;
}
/*
Retorna status e array de condições do usuário.
*/
public function ConsultarOpcoesPagamento($codigo){
sleep(10);
file_put_contents("consultar.txt", date('d/m/Y H:i:s') . " id: " . $codigo);
}
}
ignore_user_abort(true);
set_time_limit(0);
ob_start();
$options = array("uri" => "http://localhost/soap/");
$server = new SoapServer(null, $options);
require_once "negociacao.php";
$negociacao = new Negociacao()
$server->setObject($negociacao);
$server->handle();
ob_end_flush();
ob_flush();
flush();
if($negociacao->id != ''):
$negociacao->consultarOpcoesPagamento($negociacao->id);
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment