reverse_client.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * Gearman PHP Extension
  4. *
  5. * Copyright (C) 2008 James M. Luedke <contact@jamesluedke.com>,
  6. * Eric Day <eday@oddments.org>
  7. * All rights reserved.
  8. *
  9. * Use and distribution licensed under the PHP license. See
  10. * the LICENSE file in this directory for full text.
  11. */
  12. echo "Starting\n";
  13. # Create our client object.
  14. $gmclient= new GearmanClient();
  15. # Add default server (localhost).
  16. $gmclient->addServer();
  17. echo "Sending job\n";
  18. # Send reverse job
  19. do
  20. {
  21. $result = $gmclient->doNormal("reverse", "Hello!");
  22. # Check for various return packets and errors.
  23. switch($gmclient->returnCode())
  24. {
  25. case GEARMAN_WORK_DATA:
  26. echo "Data: $result\n";
  27. break;
  28. case GEARMAN_WORK_STATUS:
  29. list($numerator, $denominator)= $gmclient->doStatus();
  30. echo "Status: $numerator/$denominator complete\n";
  31. break;
  32. case GEARMAN_SUCCESS:
  33. break;
  34. default:
  35. echo "RET: " . $gmclient->returnCode() . "\n";
  36. exit;
  37. }
  38. }
  39. while($gmclient->returnCode() != GEARMAN_SUCCESS);
  40. echo "Success: $result\n";
  41. ?>