Native Conveyor / Acknowledgment Native clients only
Acknowledgment
Acknowledgments let native Conveyor clients confirm receipt of server messages.
Enable acknowledgments
server.phpnative
<?php
use Conveyor\Constants;
use Conveyor\ConveyorServer;
require __DIR__ . '/vendor/autoload.php';
(new ConveyorServer())
->port(8989)
->conveyorOptions([
Constants::USE_ACKNOWLEDGMENT => true,
Constants::ACKNOWLEDGMENT_ATTEMPTS => 3,
Constants::ACKNOWLEDGMENT_TIMOUT => 0.5,
])
->start();USE_ACKNOWLEDGMENT
trueACKNOWLEDGMENT_ATTEMPTS
3ACKNOWLEDGMENT_TIMOUT
0.5Once enabled, outgoing pushed messages receive an id.
Acknowledge a message
Server pushes message +
id
Client processes it
acknowledge-action
jsonclient → server
{
"action": "acknowledge-action",
"data": "the-message-id"
}The initial connection-info message also includes an id when acknowledgment is enabled.
Client responsibility
- Store the message ids you receive.
- Send the acknowledgment after the message has been processed.
- Keep acknowledgment logic close to the message handling code, so dropped acknowledgments are easier to debug.