3 #include "socket_bundle.h"
4 #include "jserver-c_session.h"
8 struct jclient_node_struct {
11 struct jclient_node_struct* next;
12 jserver_session* session;
13 struct jserver_struct* parent;
15 typedef struct jclient_node_struct jclient_node;
17 struct jserver_struct {
21 typedef struct jserver_struct jserver;
23 /* allocats and sets up a new jserver */
24 jserver* jserver_init();
26 void jserver_socket_closed(void* blob, int sock_id);
28 /* disconnects all client, deallocates the server and all clients */
31 /* opens the inet and unix sockets that we're listening on
32 if(port < 1) no inet socket is opened
33 if unix_path == NULL no unix socket is opened
34 returns -1 on error */
35 int jserver_connect(jserver* js, int port, char* unix_path);
37 /* allocates a new client node */
38 jclient_node* _new_jclient_node(int id);
40 void _free_jclient_node(jclient_node* node);
42 int _jserver_push_client_data(jclient_node* node, char* data);
44 void jclient_on_parse_error(void* blob, jserver_session* session);
46 /* called when a newly connected client reveals its address */
47 void jserver_client_from_found(void* blob, char* from);
48 void jserver_client_login_init(void* blob, char* reply);
49 void jserver_client_login_ok(void* blob);
50 void jserver_client_finish(void* blob);
52 /* allocates a new client node and adds it to the set */
53 jclient_node* _jserver_add_client(jserver* js, int id);
55 /* removes and frees a client node */
56 void _jserver_remove_client(jserver* js, char* addr);
58 void _jserver_remove_client_id(jserver* js, int id);
60 /* finds a client node by addr */
61 jclient_node* jserver_find_client(jserver* js, char* addr);
63 jclient_node* jserver_find_client_id(jserver* js, int id);
65 /* sends msg to client at 'to_addr'. from_id is the id
66 of the sending client (if from_id > 0). used for error replies */
67 int jserver_send(jserver* js, int from_id, char* to_addr, const char* msg_xml);
69 /* send the data to the client with client_id */
70 int jserver_send_id(int client_id, const char* msg_xml);
72 /* waits for any incoming data */
73 int jserver_wait(jserver* js);
75 /* handles all incoming socket data */
76 void jserver_handle_request(void* js,
77 socket_manager* mgr, int sock_id, char* data, int parent_id );
80 /* called by the jserver_session when any client has a
81 complete message parsed and ready to forward on */
82 void jserver_client_handle_msg(
83 void* blob, char* xml, char* from, char* to );