gwenhywfar  5.14.1
endpoint.h
Go to the documentation of this file.
1 /****************************************************************************
2  * This file is part of the project Gwenhywfar.
3  * Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
4  *
5  * The license for this file can be found in the file COPYING which you
6  * should have received along with this file.
7  ****************************************************************************/
8 
9 #ifndef GWEN_MSG_ENDPOINT_H
10 #define GWEN_MSG_ENDPOINT_H
11 
12 
13 #include <gwenhywfar/inherit.h>
14 #include <gwenhywfar/tree2.h>
15 #include <gwenhywfar/inetsocket.h>
16 
17 
18 
19 #define GWEN_MSG_ENDPOINT_FLAGS_DELETE 0x80000000u
20 #define GWEN_MSG_ENDPOINT_FLAGS_NOIO 0x40000000u
21 
22 
23 #define GWEN_MSG_ENDPOINT_STATE_UNCONNECTED 0
24 #define GWEN_MSG_ENDPOINT_STATE_CONNECTING 1
25 #define GWEN_MSG_ENDPOINT_STATE_CONNECTED 2
26 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 
40 
41 #ifdef __cplusplus
42 }
43 #endif
44 
45 
46 #include <gwenhywfar/msg.h>
47 
48 #include <time.h>
49 
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
181 
182 
184  GWEN_SOCKETSET *readSet,
185  GWEN_SOCKETSET *writeSet,
186  GWEN_SOCKETSET *xSet);
187 
189  GWEN_SOCKETSET *readSet,
190  GWEN_SOCKETSET *writeSet,
191  GWEN_SOCKETSET *xSet);
192 
193 
194 
195 GWENHYWFAR_API GWEN_MSG_ENDPOINT *GWEN_MsgEndpoint_new(const char *name, int groupId);
197 
199 
200 
203 
206 
210 
215 
218 
220 
221 
225 
230 
231 
233 
236 
237 
238 
240  GWEN_SOCKETSET *readSet,
241  GWEN_SOCKETSET *writeSet,
242  GWEN_SOCKETSET *xSet);
243 
245  GWEN_SOCKETSET *readSet,
246  GWEN_SOCKETSET *writeSet,
247  GWEN_SOCKETSET *xSet);
248 
259 
260 
261 
262 
263 
265  GWEN_SOCKETSET *readSet,
266  GWEN_SOCKETSET *writeSet,
267  GWEN_SOCKETSET *xSet);
268 
270  GWEN_SOCKETSET *readSet,
271  GWEN_SOCKETSET *writeSet,
272  GWEN_SOCKETSET *xSet);
273 
282 
283 
285 
286 
287 
288 
289 GWENHYWFAR_API int GWEN_MsgEndpoint_ReadFromSocket(GWEN_MSG_ENDPOINT *ep, uint8_t *bufferPtr, uint32_t bufferLen);
290 GWENHYWFAR_API int GWEN_MsgEndpoint_WriteToSocket(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPtr, uint32_t bufferLen);
292 
293 
294 
302 
303 
304 
305 
310 
311 
314 #ifdef __cplusplus
315 }
316 #endif
317 
318 
319 #endif
320 
321 
GWENHYWFAR_API GWEN_SOCKET * GWEN_MsgEndpoint_GetSocket(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:104
void(* GWEN_MSG_ENDPOINT_ADDSOCKETS_FN)(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition: endpoint.h:183
GWENHYWFAR_API int GWEN_MsgEndpoint_WriteToSocket(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPtr, uint32_t bufferLen)
Definition: endpoint.c:444
GWENHYWFAR_API void GWEN_MsgEndpoint_SetFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f)
Definition: endpoint.c:161
struct GWEN_MSG_ENDPOINT GWEN_MSG_ENDPOINT
Object which can send and receive messages (base class).
Definition: endpoint.h:37
GWENHYWFAR_API void GWEN_MsgEndpoint_AddReceivedMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
Definition: endpoint.c:221
GWENHYWFAR_API void GWEN_MsgEndpoint_AddSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition: endpoint.c:289
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_GetCurrentlyReceivedMsg(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:274
GWENHYWFAR_API int GWEN_MsgEndpoint_DiscardInput(GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:460
GWENHYWFAR_API uint32_t GWEN_MsgEndpoint_GetFlags(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:154
GWENHYWFAR_API void GWEN_MsgEndpoint_Attach(GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:53
GWENHYWFAR_API int GWEN_MsgEndpoint_GetGroupId(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:97
struct GWEN_SOCKETSETSTRUCT GWEN_SOCKETSET
Definition: inetsocket.h:45
GWENHYWFAR_API void GWEN_MsgEndpoint_SetDefaultMessageSize(GWEN_MSG_ENDPOINT *ep, int i)
Definition: endpoint.c:192
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenIoLoop(GWEN_MSG_ENDPOINT *ep, int timeout)
Definition: endpoint.c:392
GWENHYWFAR_API void GWEN_MsgEndpoint_SetCurrentlyReceivedMsg(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
Definition: endpoint.c:281
GWENHYWFAR_API GWEN_MSG_ENDPOINT * GWEN_MsgEndpoint_new(const char *name, int groupId)
Definition: endpoint.c:31
GWENHYWFAR_API time_t GWEN_MsgEndpoint_GetTimeOfLastStateChange(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:144
GWENHYWFAR_API void GWEN_MsgEndpoint_SetSocket(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKET *sk)
Definition: endpoint.c:111
#define GWEN_INHERIT_FUNCTION_LIB_DEFS(t, decl)
Definition: inherit.h:125
GWENHYWFAR_API GWEN_MSG_LIST * GWEN_MsgEndpoint_GetReceivedMessageList(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:207
GWENHYWFAR_API void GWEN_MsgEndpoint_free(GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:61
GWENHYWFAR_API int GWEN_MsgEndpoint_HaveMessageToSend(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:267
GWENHYWFAR_API void GWEN_MsgEndpoint_IoLoop(GWEN_MSG_ENDPOINT *ep, int timeout)
Definition: endpoint.c:360
GWENHYWFAR_API int GWEN_MsgEndpoint_GetState(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:124
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_GetFirstSendMessage(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:260
#define GWENHYWFAR_API
Definition: gwenhywfarapi.h:67
GWENHYWFAR_API void GWEN_MsgEndpoint_AddSendMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
Definition: endpoint.c:250
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_TakeFirstReceivedMessage(GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:238
GWENHYWFAR_API void GWEN_MsgEndpoint_RemoveUnconnectedAndEmptyChildren(GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:337
GWENHYWFAR_API void GWEN_MsgEndpoint_DelFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f)
Definition: endpoint.c:177
GWENHYWFAR_API void GWEN_MsgEndpoint_Disconnect(GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:483
struct GWEN_MSG GWEN_MSG
Definition: msg.h:24
GWENHYWFAR_API int GWEN_MsgEndpoint_GetDefaultMessageSize(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:185
GWENHYWFAR_API int GWEN_MsgEndpoint_ReadFromSocket(GWEN_MSG_ENDPOINT *ep, uint8_t *bufferPtr, uint32_t bufferLen)
Definition: endpoint.c:424
void(* GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN)(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition: endpoint.h:188
GWENHYWFAR_API void GWEN_MsgEndpoint_CheckSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition: endpoint.c:297
GWEN_TREE2_FUNCTION_LIB_DEFS(GWEN_JSON_ELEM, GWEN_JsonElement, GWENHYWFAR_API)
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenCheckSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition: endpoint.c:321
struct GWEN_SOCKET GWEN_SOCKET
Definition: inetsocket.h:44
GWENHYWFAR_API void GWEN_MsgEndpoint_SetState(GWEN_MSG_ENDPOINT *ep, int m)
Definition: endpoint.c:131
GWENHYWFAR_API const char * GWEN_MsgEndpoint_GetName(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:90
GWENHYWFAR_API GWEN_MSG * GWEN_MsgEndpoint_GetFirstReceivedMessage(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:231
GWENHYWFAR_API void GWEN_MsgEndpoint_ChildrenAddSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
Definition: endpoint.c:305
GWENHYWFAR_API void GWEN_MsgEndpoint_AddFlags(GWEN_MSG_ENDPOINT *ep, uint32_t f)
Definition: endpoint.c:169
GWENHYWFAR_API GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN GWEN_MsgEndpoint_SetCheckSocketsFn(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN fn)
Definition: endpoint.c:518
GWENHYWFAR_API uint32_t GWEN_MsgEndpoint_GetNextMessageId(GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:200
GWENHYWFAR_API GWEN_MSG_LIST * GWEN_MsgEndpoint_GetSendMessageList(const GWEN_MSG_ENDPOINT *ep)
Definition: endpoint.c:214
GWENHYWFAR_API GWEN_MSG_ENDPOINT_ADDSOCKETS_FN GWEN_MsgEndpoint_SetAddSocketsFn(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT_ADDSOCKETS_FN fn)
Definition: endpoint.c:504