|
10969
|
1
|
|
|
2 #ifndef _MW_CLIENT_H
|
|
|
3 #define _MW_CLIENT_H
|
|
|
4
|
|
|
5
|
|
|
6 #include <glib.h>
|
|
|
7 #include <glib/glist.h>
|
|
|
8
|
|
|
9
|
|
|
10 /* place-holders */
|
|
|
11 struct mwChannel;
|
|
|
12 struct mwClient;
|
|
|
13 struct mwClientHandler;
|
|
|
14 struct mwConnection;
|
|
|
15 struct mwConnectionHandler;
|
|
|
16 struct mwMessage;
|
|
|
17 struct mwService;
|
|
|
18 struct mwSession;
|
|
|
19
|
|
|
20
|
|
|
21
|
|
|
22 /* @file mw_client.h
|
|
|
23
|
|
|
24 */
|
|
|
25
|
|
|
26
|
|
|
27
|
|
|
28 /* @section Client
|
|
|
29
|
|
|
30 */
|
|
|
31 /*@{*/
|
|
|
32
|
|
|
33
|
|
|
34 struct mwClient;
|
|
|
35
|
|
|
36
|
|
|
37 typedef (struct mwConnectionHandler *)(*mwClientConnect)
|
|
|
38 (struct mwClient *c, const char *host);
|
|
|
39
|
|
|
40
|
|
|
41 struct mwClientHandler {
|
|
|
42 mwClientConnect connect;
|
|
|
43 }
|
|
|
44
|
|
|
45
|
|
|
46 struct mwClient *
|
|
|
47 mwClient_new(struct mwClientHandler *h);
|
|
|
48
|
|
|
49
|
|
|
50 struct mwChannel *
|
|
|
51 mwClient_newChannel(struct mwClient *client,
|
|
|
52 struct mwService *srvc);
|
|
|
53
|
|
|
54
|
|
|
55 struct mwChannel *
|
|
|
56 mwClient_newMasterChannel(struct mwClient *client,
|
|
|
57 struct mwSession *session);
|
|
|
58
|
|
|
59
|
|
|
60 int mwClient_sendKeepAlive(struct mwClient *client);
|
|
|
61
|
|
|
62
|
|
|
63 void mwClient_setUsesCountByte(struct mwClient *client,
|
|
|
64 gboolean use);
|
|
|
65
|
|
|
66
|
|
|
67 gboolean mwClient_getUsesCountByte(struct mwClient *client);
|
|
|
68
|
|
|
69
|
|
|
70 void mwClient_destroy(struct mwClient *client);
|
|
|
71
|
|
|
72
|
|
|
73 /*@}*/
|
|
|
74
|
|
|
75
|
|
|
76
|
|
|
77 /* @section Connection
|
|
|
78
|
|
|
79 */
|
|
|
80 /*{*/
|
|
|
81
|
|
|
82
|
|
|
83 struct mwConnection;
|
|
|
84
|
|
|
85
|
|
|
86 typedef (int)(*mwConnectionWrite)
|
|
|
87 (struct mwConnection *c, const char *buf, gsize len);
|
|
|
88
|
|
|
89
|
|
|
90 typedef (void)(*mwConnectionClose)
|
|
|
91 (struct mwConnection *c);
|
|
|
92
|
|
|
93
|
|
|
94 struct mwConnectionHandler {
|
|
|
95 mwConnectionWrite write;
|
|
|
96 mwConnectionClose close;
|
|
|
97 }
|
|
|
98
|
|
|
99
|
|
|
100 struct mwConnection *
|
|
|
101 mwConnection_new(struct mwConnectionHandler *h);
|
|
|
102
|
|
|
103
|
|
|
104 void mwConnection_recv(struct mwConnection *connection,
|
|
|
105 const char *buf,
|
|
|
106 gsize len);
|
|
|
107
|
|
|
108
|
|
|
109 void mwConnection_destroy(struct mwConnection *connection);
|
|
|
110
|
|
|
111
|
|
|
112 /*@}*/
|
|
|
113
|
|
|
114
|
|
|
115
|
|
|
116 /* @section Channel
|
|
|
117
|
|
|
118 */
|
|
|
119 /*@{*/
|
|
|
120
|
|
|
121
|
|
|
122 struct mwChannel;
|
|
|
123
|
|
|
124
|
|
|
125 int mwChannel_sendMessage(struct mwChannel *channel,
|
|
|
126 struct mwMessage *msg);
|
|
|
127
|
|
|
128
|
|
|
129 int mwChannel_send(struct mwChannel *channel,
|
|
|
130 guint32 type,
|
|
|
131 guint32 options,
|
|
|
132 struct mwOpaque *data);
|
|
|
133
|
|
|
134
|
|
|
135 int mwChannel_destroy(struct mwChannel *channel,
|
|
|
136 guint32 reason,
|
|
|
137 struct mwOpaque *info);
|
|
|
138
|
|
|
139
|
|
|
140 gboolean mwChannel_isMasterChannel(struct mwChannel *channel);
|
|
|
141
|
|
|
142
|
|
|
143 guint32 mwChannel_getId(struct mwChannel *channel);
|
|
|
144
|
|
|
145
|
|
|
146 enum mwChannelState mwChannel_getState(struct mwChannel *channel);
|
|
|
147
|
|
|
148
|
|
|
149
|
|
|
150 /*@}*/
|
|
|
151
|
|
|
152
|
|
|
153
|
|
|
154 #endif
|