Browse Source

update response builder, cleanup session on handler complete

main
ghost 7 months ago
parent
commit
eb52f6c2d9
  1. 46
      src/server.php

46
src/server.php

@ -168,8 +168,26 @@ $server->setPending( @@ -168,8 +168,26 @@ $server->setPending(
);
}
return $session[$connect]['code'] == $request ? implode(PHP_EOL, $config->nps->action->pending->message->success) . PHP_EOL
: implode(PHP_EOL, $config->nps->action->pending->message->failure) . PHP_EOL;
// Session valid
if ($session[$connect]['code'] == $request)
{
// Return success message
return implode(
PHP_EOL,
$config->nps->action->pending->message->success
) . PHP_EOL;
}
// @TODO disconnect, stop handler
// Cleanup session
unset($session[$connect]);
// Return failure message
return implode(
PHP_EOL,
$config->nps->action->pending->message->failure
) . PHP_EOL;
}
);
@ -195,8 +213,25 @@ $server->setHandler( @@ -195,8 +213,25 @@ $server->setHandler(
$content
);
// Build response
if ($session[$connect]['code'] == $request)
{
// @TODO save content in blockchain with kevacoin-php
$response = implode(
PHP_EOL,
$config->nps->action->handler->message->success
) . PHP_EOL;
}
else
{
$response = implode(
PHP_EOL,
$config->nps->action->handler->message->failure
) . PHP_EOL;
}
// Debug request on enabled
if ($config->nps->action->handler->debug->enabled)
{
@ -226,8 +261,11 @@ $server->setHandler( @@ -226,8 +261,11 @@ $server->setHandler(
);
}
return $session[$connect]['code'] == $request ? implode(PHP_EOL, $config->nps->action->handler->message->success) . PHP_EOL
: implode(PHP_EOL, $config->nps->action->handler->message->failure) . PHP_EOL;
// Cleanup session
unset($session[$connect]);
// Result
return $response;
}
);

Loading…
Cancel
Save