#ifndef MSG_BROKER_H
#define MSG_BROKER_H
#include <stdint.h>

typedef struct MsgBroker_Handle_S MsgBroker_Handle_T;

/* Message callback context — all fields accessed in kdp2_host_stream.c msg_callback */
typedef struct {
    uint32_t  msg_type;
    void     *data;
    uint32_t  size;
    char     *pszHost;       /* target module name */
    char     *pszCmd;        /* command string */
    void     *pbyData;       /* command payload */
    uint32_t  bHasResponse;
    uint32_t  dwDataSize;
    uint32_t  _pad[4];
} MsgContext;

/* System runtime suspend/resume command strings */
#define SR_MODULE_NAME  "sr"
#define SUSPEND_CMD     "suspend"
#define RESUME_CMD      "resume"

int MsgBroker_Init(void);
int MsgBroker_Deinit(void);
int MsgBroker_Send(const char *topic, void *data, uint32_t size);
int MsgBroker_Recv(const char *topic, void *data, uint32_t size, int timeout_ms);
int MsgBroker_RegisterMsg(const char *topic);
int MsgBroker_UnRegisterMsg(void);
int MsgBroker_Run(const char *topic,
                  void (*callback)(MsgContext *ctx, void *user),
                  void *user_data,
                  int  *terminate);
int MsgBroker_SuspendAckMsg(void);
#endif
