passdb-to-server.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. The passdb module keeps track of the local copy of the bus pass
  2. database by polling the server from time to time to ask for updates
  3. newer than the latest locally recorded sequence number. Each message
  4. is a single line of ASCII text with tab delimited fields (there is no
  5. valid reason to allow a tab in any of the fields, any tabs inside the
  6. fields should be translated to single spaces) and terminated by a
  7. newline.
  8. When the client wants to inquire about any new records, it
  9. issues a query request in this format:
  10. QUERY 1234567890
  11. Where QUERY is the command, then a tab character, then the
  12. newest sequence number which the local client has in its database,
  13. followed by a newline. The QUERY record has the following fields:
  14. 0) Command = QUERY
  15. 1) Sequence Number = Newest locally stored sequence number. If
  16. this number is zero, it indicates a table
  17. flush to the server, triggering a flush
  18. marker to be sent before the first reply
  19. record.
  20. The server will respond with a sequence of bus pass updates
  21. with the following allowable formats:
  22. UPDATE 1234567891 54321 2:771231232 35:111:2357 ORG-NRIDE 7
  23. DELETE 1234567892 938773
  24. The UPDATE record has the following fields:
  25. 0) Command = UPDATE
  26. 1) Sequence Number = Sequence number of this update.
  27. 2) Rider ID = Unique ID of this rider's record.
  28. 3) Magstripe Token = The magnetic stripe token in the format of
  29. track:track_data by which this rider is
  30. recognized.
  31. 4) RFID Token = The RFID token in the format of
  32. n_bits:site:id by which this rider is
  33. recognized.
  34. 5) Rule Name = The name of the rule to apply to this rider.
  35. 6) Rule Parameter = An (optionally blank) parameter to pass to the
  36. rule that validates this rider.
  37. The DELETE record has the following fields:
  38. 0) Command = DELETE
  39. 1) Sequence Number = The sequence number of this deletion.
  40. 2) Rider ID = Unique ID of this rider's record.
  41. If the client requests a query from Sequence Number 0, the
  42. server will send a flush marker which will prompt the client to flush
  43. its tables before processing any further records. This is sent to
  44. prevent lag from causing a previous request's records from polluting
  45. a clean refresh. It looks like this:
  46. ZFLUSH 523498
  47. <523498 octets of binary data>
  48. 0) Command = ZFLUSH
  49. 1) Data Size = How many bytes of zlib compressed (with deflate)
  50. binary data follow before the command stream picks
  51. up again.
  52. A flush is also triggered by the server if a query is sent with
  53. an extremely old sequence number, or a sequence number greater than the
  54. newest sequence number on the master server.
  55. After a flush in completed, the server MUST send a ZFLUSHDONE
  56. command so the client can become aware that it is no longer in ZFLUSH mode.
  57. Doing so will trigger the client to actually apply the compressed data which
  58. it received in the ZFLUSH blob.
  59. This looks like this:
  60. ZFLUSHDONE
  61. 0) Command = ZFLUSHDONE
  62. NOP
  63. 0) Command = NOP
  64. If a QUERY message results in NO data sent back to the requesting
  65. client, an NOP command will be sent to indicate that the connection is still
  66. alive. This is useful for debugging, but has little value for end-user
  67. display.
  68. -----------------------OBSOLETE----------------------------------------
  69. - If the client requests a query from Sequence Number 0, the
  70. -server will send a flush marker which will prompt the client to flush
  71. -its tables before processing any further records. This is sent to
  72. -prevent lag from causing a previous request's records from polluting
  73. -a clean refresh. It looks like this:
  74. -
  75. -FLUSH
  76. -
  77. -0) Command = FLUSH
  78. -
  79. - A flush is also triggered by the server if a query is sent with
  80. -an extremely old sequence number, or a sequence number greater than the
  81. -newest sequence number on the master server.
  82. -
  83. - After a flush in completed, the server should send a FLUSHDONE
  84. -command so the client can become aware that it is no longer in FLUSH mode.
  85. -This looks like thise:
  86. -
  87. -FLUSHDONE
  88. -
  89. -0) Command = FLUSHDONE