+/* Returns the current status of 's'. If 's' is NULL or is disconnected, this
+ * is 0, otherwise it is the status of the connection, as reported by
+ * jsonrpc_get_status(). */
+int
+jsonrpc_session_get_status(const struct jsonrpc_session *s)
+{
+ return s && s->rpc ? jsonrpc_get_status(s->rpc) : 0;
+}
+
+/* Returns the last error reported on a connection by 's'. The return value is
+ * 0 only if no connection made by 's' has ever encountered an error. See
+ * jsonrpc_get_status() for return value interpretation. */
+int
+jsonrpc_session_get_last_error(const struct jsonrpc_session *s)
+{
+ return s->last_error;
+}
+
+/* Populates 'stats' with statistics from 's'. */
+void
+jsonrpc_session_get_reconnect_stats(const struct jsonrpc_session *s,
+ struct reconnect_stats *stats)
+{
+ reconnect_get_stats(s->reconnect, time_msec(), stats);
+}
+
+/* Enables 's' to reconnect to the peer if the connection drops. */
+void
+jsonrpc_session_enable_reconnect(struct jsonrpc_session *s)
+{
+ reconnect_set_max_tries(s->reconnect, UINT_MAX);
+ reconnect_set_backoff(s->reconnect, RECONNECT_DEFAULT_MIN_BACKOFF,
+ RECONNECT_DEFAULT_MAX_BACKOFF);
+}
+
+/* Forces 's' to drop its connection (if any) and reconnect. */