85 lines
1.7 KiB
C
85 lines
1.7 KiB
C
/****************************************************************************
|
|
* This file is part of the project AqHome.
|
|
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
|
*
|
|
* The license for this file can be found in the file COPYING which you
|
|
* should have received along with this file.
|
|
****************************************************************************/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include <config.h>
|
|
#endif
|
|
|
|
|
|
#include "aqhome/ipc/endpoint_ipc_tcpc_p.h"
|
|
|
|
#include <gwenhywfar/endpoint_tcpc.h>
|
|
#include <gwenhywfar/endpoint_ipc.h>
|
|
#include <gwenhywfar/debug.h>
|
|
|
|
|
|
|
|
|
|
#define AQH_MSG_ENDPOINT_IPCC_NAME "ipc_tcpc"
|
|
|
|
|
|
GWEN_INHERIT(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_IPCC)
|
|
|
|
|
|
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
|
|
static void _run(GWEN_MSG_ENDPOINT *ep);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GWEN_MSG_ENDPOINT *AQH_IpcTcpClientEndpoint_new(const char *host, int port, const char *name, int groupId)
|
|
{
|
|
GWEN_MSG_ENDPOINT *ep;
|
|
AQH_ENDPOINT_IPCC *xep;
|
|
|
|
ep=GWEN_TcpcEndpoint_new(host, port, name?name:AQH_MSG_ENDPOINT_IPCC_NAME, groupId);
|
|
if (ep==NULL) {
|
|
DBG_INFO(AQH_LOGDOMAIN, "here");
|
|
return NULL;
|
|
}
|
|
GWEN_IpcEndpoint_Extend(ep);
|
|
|
|
GWEN_NEW_OBJECT(AQH_ENDPOINT_IPCC, xep);
|
|
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_IPCC, ep, xep, _freeData);
|
|
|
|
xep->previousRunFn=GWEN_MsgEndpoint_SetRunFn(ep, _run);
|
|
|
|
return ep;
|
|
}
|
|
|
|
|
|
|
|
void _freeData(void *bp, void *p)
|
|
{
|
|
AQH_ENDPOINT_IPCC *xep;
|
|
|
|
xep=(AQH_ENDPOINT_IPCC*) p;
|
|
GWEN_FREE_OBJECT(xep);
|
|
}
|
|
|
|
|
|
|
|
void _run(GWEN_MSG_ENDPOINT *ep)
|
|
{
|
|
AQH_ENDPOINT_IPCC *xep;
|
|
|
|
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_IPCC, ep);
|
|
if (xep) {
|
|
if (xep->previousRunFn)
|
|
xep->previousRunFn(ep);
|
|
/* TODO: send CONNECT_REQ message, check for CONNECT_RSP */
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|