コード例 #1
0
ファイル: index.php プロジェクト: mssmello/tokbox2
        }
        $app->response->headers->set('Content-Type', 'application/json');
        $app->response->setBody(json_encode($responseData));
    }
});
// Customer dequeues by cancelling or leaving the page
//
// Dequeue the specific help session from the help queue.
$app->delete('/help/queue/:queueId', function ($queueId) use($app, $redis) {
    $redisResponse = $redis->lrem(HELP_QUEUE_KEY, 0, $queueId);
    if (!handleRedisError($redisResponse, $app, 'Não foi possível remover a sessão da fila de atendimento.')) {
        return;
    }
    $helpSessionKey = $queueId;
    $redisResponse = $redis->del($helpSessionKey);
    if (!handleRedisError($redisResponse, $app, 'Não foi possível remover a sessão após a retirada da fila.')) {
        return;
    }
    $app->response->setStatus(204);
});
/* ------------------------------------------------------------------------------------------------
 * Application Start
 * -----------------------------------------------------------------------------------------------*/
$app->run();
/* ------------------------------------------------------------------------------------------------
 * Helper functions
 * -----------------------------------------------------------------------------------------------*/
function handleRedisError($redisResponse, $app, $message = '')
{
    $success = true;
    if ($redisResponse instanceof RedisErrorInterface) {
コード例 #2
0
ファイル: index.php プロジェクト: apg23/servicekit-php
        }
        $app->response->headers->set('Content-Type', 'application/json');
        $app->response->setBody(json_encode($responseData));
    }
});
// Customer dequeues by cancelling or leaving the page
//
// Dequeue the specific help session from the help queue.
$app->delete('/help/queue/:queueId', function ($queueId) use($app, $redis) {
    $redisResponse = $redis->lrem(HELP_QUEUE_KEY, 0, $queueId);
    if (!handleRedisError($redisResponse, $app, 'Could not remove the help session from the queue.')) {
        return;
    }
    $helpSessionKey = $queueId;
    $redisResponse = $redis->del($helpSessionKey);
    if (!handleRedisError($redisResponse, $app, 'Could not delete the help session after removing from the queue.')) {
        return;
    }
    $app->response->setStatus(204);
});
/* ------------------------------------------------------------------------------------------------
 * Application Start
 * -----------------------------------------------------------------------------------------------*/
$app->run();
/* ------------------------------------------------------------------------------------------------
 * Helper functions
 * -----------------------------------------------------------------------------------------------*/
function handleRedisError($redisResponse, $app, $message = '')
{
    $success = true;
    if ($redisResponse instanceof RedisErrorInterface) {