-/** @brief Return true if @c c is connected
- *
- * By connected it is meant that commands have a reasonable chance of being
- * processed soon, not merely that a TCP connection exists - for instance if
- * the client is still authenticating then that does not count as connected.
- */
-int disorder_eclient_connected(const disorder_eclient *c) {
- switch(c->state) {
- case state_disconnected:
- case state_connecting:
- case state_connected:
- return 0;
- case state_idle:
- case state_cmdresponse:
- case state_body:
- case state_log:
- return 1;
- }
- assert(!"reached");
+/** @brief Return current state */
+unsigned long disorder_eclient_state(const disorder_eclient *c) {
+ return c->statebits | (c->state > state_connected ? DISORDER_CONNECTED : 0);