]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/jserver/jserver-c.h
fixed some a bug in jserver, added some debug lines
[OpenSRF.git] / src / jserver / jserver-c.h
1 #include "utils.h"
2 #include "logging.h"
3 #include "socket_bundle.h"
4 #include "jserver-c_session.h"
5
6
7
8 struct jclient_node_struct {
9         int id;
10         char* addr;
11         struct jclient_node_struct* next;
12         jserver_session* session;
13         struct jserver_struct* parent;
14 };
15 typedef struct jclient_node_struct jclient_node;
16
17 struct jserver_struct {
18         jclient_node* client;
19         socket_manager* mgr;
20 };
21 typedef struct jserver_struct jserver;
22
23 /* allocats and sets up a new jserver */
24 jserver* jserver_init();
25
26 void jserver_socket_closed(void* blob, int sock_id);
27
28 /* disconnects all client, deallocates the server and all clients */
29 void jserver_free();
30
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);
36
37 /* allocates a new client node */
38 jclient_node* _new_jclient_node(int id);
39
40 void _free_jclient_node(jclient_node* node);
41
42 int _jserver_push_client_data(jclient_node* node, char* data);
43
44 void jclient_on_parse_error(void* blob, jserver_session* session);
45
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);
51
52 /* allocates a new client node and adds it to the set */
53 jclient_node* _jserver_add_client(jserver* js, int id);
54
55 /* removes and frees a client node */
56 void _jserver_remove_client(jserver* js, char* addr);
57
58 void _jserver_remove_client_id(jserver* js, int id);
59
60 /* finds a client node by addr */
61 jclient_node* jserver_find_client(jserver* js, char* addr);
62
63 jclient_node* jserver_find_client_id(jserver* js, int id);
64
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);
68
69 /* send the data to the client with client_id */
70 int jserver_send_id(int client_id, const char* msg_xml);
71
72 /* waits for any incoming data */
73 int jserver_wait(jserver* js);
74
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 ); 
78
79
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 );