AbstractMessage.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Amf
  17. * @subpackage Value
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * This is the default Implementation of Message, which provides
  23. * a convenient base for behavior and association of common endpoints
  24. *
  25. * @package Zend_Amf
  26. * @subpackage Value
  27. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. */
  30. class Zend_Amf_Value_Messaging_AbstractMessage
  31. {
  32. /**
  33. * @var string Client identifier
  34. */
  35. public $clientId;
  36. /**
  37. * @var string Destination
  38. */
  39. public $destination;
  40. /**
  41. * @var string Message identifier
  42. */
  43. public $messageId;
  44. /**
  45. * @var int Message timestamp
  46. */
  47. public $timestamp;
  48. /**
  49. * @var int Message TTL
  50. */
  51. public $timeToLive;
  52. /**
  53. * @var object Message headers
  54. */
  55. public $headers;
  56. /**
  57. * @var string Message body
  58. */
  59. public $body;
  60. /**
  61. * generate a unique id
  62. *
  63. * Format is: ########-####-####-####-############
  64. * Where # is an uppercase letter or number
  65. * example: 6D9DC7EC-A273-83A9-ABE3-00005FD752D6
  66. *
  67. * @return string
  68. */
  69. public function generateId()
  70. {
  71. return sprintf(
  72. '%08X-%04X-%04X-%02X%02X-%012X',
  73. mt_rand(),
  74. mt_rand(0, 65535),
  75. bindec(substr_replace(
  76. sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4)
  77. ),
  78. bindec(substr_replace(sprintf('%08b', mt_rand(0, 255)), '01', 5, 2)),
  79. mt_rand(0, 255),
  80. mt_rand()
  81. );
  82. }
  83. }