@@ -40,16 +40,37 @@ server_t server_init(
4040 ondisconnect_callback_t ondisconnect
4141);
4242
43+ /*
44+ * Assigns the given raft socket to the server. The server will add the socket
45+ * to the 'select' calls and give you the incoming messages.
46+ */
47+ void server_set_raft_socket (server_t server , int sock );
48+
4349/*
4450 * Starts the server. Returns 'true' on success, 'false' otherwise.
4551 */
4652bool server_start (server_t server );
4753
4854/*
49- * The main server loop. Does not return, so use the callbacks and signal
50- * handlers to add more logic.
55+ * The main server loop. Returns true if there is a raft message ready, or NULL
56+ * if timed out. Use the callbacks and signal handlers to add more logic.
57+ */
58+ bool server_tick (server_t server , int timeout_ms );
59+
60+ /*
61+ * Closes all client connections on the server and refuses to accept new ones.
62+ */
63+ void server_disable (server_t server );
64+
65+ /*
66+ * Allows the server to accept new connections.
5167 */
52- void server_loop (server_t server );
68+ void server_enable (server_t server );
69+
70+ /*
71+ * Enables or disables the server depending on the argument.
72+ */
73+ void server_set_enabled (server_t server , bool enable );
5374
5475/*
5576 * These two methods allow you to set and get your custom 'userdata' for the
@@ -98,4 +119,11 @@ bool client_message_finish(client_t client);
98119 */
99120bool client_message_shortcut (client_t client , xid_t arg );
100121
122+ /*
123+ * A shortcut to send the 'redirect' message.
124+ *
125+ * Returns 'true' on success, 'false' otherwise.
126+ */
127+ bool client_redirect (client_t client , unsigned addr , int port );
128+
101129#endif
0 commit comments