Last active
July 3, 2017 20:16
-
-
Save Gabrielr47/23fd7e402ad9e56812f5ec7816d2f40c to your computer and use it in GitHub Desktop.
processo em paralelo usando soap e ob_start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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