Session States

This pages describes possible states of a hpfeeds session. A hpfeeds implementation must follow this specification.

Client States

A hpfeed client is a program that connects to a hpfeeds server, e.g., a broker. A client session has the following possible states:

  • S_INIT: initial state
  • S_AUTH: send authentication message
  • S_SUBSCRIBE: send subscribe message
  • S_PUBLISH: send publish message
  • S_RECVMSG: receive message
  • S_ERROR: error message received
  • S_TERMINATE: final state

Subscriber State Machine

The state diagram of a client that receives messages from a feed channel is shown below. A description of the individual states can be found at the top of this page, although their names should be quite self-explanatory.

                                  +---------------------------------------+
                                  |                                       |
                                  |                                       v
                           +------+------+     +-------------+     +------------+
                     +---->|   S_AUTH    |---->| S_SUBSCRIBE |---->| S_RECVMSG  |---+
                     |     +-------------+     +-------------+     +------+-----+   |
                     |                                                    |         |
  +-------------+    |                                +-------------------+         |     +-------------+
  |   S_INIT    |----+                                |                             +---->| S_TERMINATE |
  +-------------+    |                                v                             |     +-------------+
                     |                         +-------------+                      |
                     +------------------------>|   S_ERROR   |----------------------+
                                               +-------------+

Publisher State Machine

The state diagram for a client that publishes messages in a channel is quite similar to the previous one, only the S_RECVMSG state has been replaced by S_PUBLISH.

                                  +---------------------------------------+
                                  |                                       |
                                  |                                       v
                           +------+------+     +-------------+     +------------+
                     +---->|   S_AUTH    |---->| S_SUBSCRIBE |---->| S_PUBLISH  |---+
                     |     +-------------+     +-------------+     +------+-----+   |
                     |                                                    |         |
  +-------------+    |                                +-------------------+         |     +-------------+
  |   S_INIT    |----+                                |                             +---->| S_TERMINATE |
  +-------------+    |                                v                             |     +-------------+
                     |                         +-------------+                      |
                     +------------------------>|   S_ERROR   |----------------------+
                                               +-------------+

Combined State Machine

A combined diagram for a client that both receives and publishes messages is a little more complex:

                                   +--------------------------------------------+
                                   |                                            |
                                   |                                            v
                                   |                                      +-----------+
                                   |                   +----------------->| S_PUBLISH |------------+
                                   |                   |                  +-----+-----+            |
                                   |                   |                        |                  |
                            +------+------+     +------+------+                 |                  |
                      +---->|   S_AUTH    |---->| S_SUBSCRIBE |-----+           |                  |
                      |     +------+------+     +------+------+     |           |                  |
                      |            |                                |           v                  v
                      |            |                                |     +-----------+     +-------------+
                      |            |                                +---->| S_RECVMSG |---->| S_TERMINATE |
                      |            |                                      +-----------+     +-------------+
                      |            |                                         ^    |                ^
  +-------------+     |            |                                         |    |                |
  |   S_INIT    |---->+            +-----------------------------------------+    |                |
  +-------------+     |                                                           |                |
                      |                                                           |                |
                      |                                +--------------------------+                |
                      |                                |                                           |
                      |                                v                                           |
                      |                         +-------------+                                    |
                      +------------------------>|   S_ERROR   |------------------------------------+
                                                +-------------+

Server States

To be added.