55 lines
1.6 KiB
C
55 lines
1.6 KiB
C
/*
|
|
* msg_util.h
|
|
*
|
|
* Created on: 2020年7月6日
|
|
* Author: Administrator
|
|
*/
|
|
|
|
#ifndef THIRDLIBS_COMMON_MSG_UTIL_H_
|
|
#define THIRDLIBS_COMMON_MSG_UTIL_H_
|
|
|
|
#include "debug.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef int (* PROCESS_CB)(char * client_handle, int cmd, unsigned char * pbuf, int size, void * user_data);
|
|
typedef int (* EVENT_CB)(int event, void * event_info, void * user_data);
|
|
|
|
typedef enum _msg_event_e {
|
|
MSG_EVENT_NONE = 0x1000,
|
|
MSG_EVENT_CLIENT_DISCONNECTED,
|
|
MSG_EVENT_CLIENT_CONNECTED,
|
|
MSG_EVENT_PROCESS_TIMEOUT,
|
|
MSG_EVENT_MSG_FULL,
|
|
MSG_EVENT_BUTT
|
|
} MSG_EVENT_E;
|
|
|
|
typedef enum _msg_attr_e {
|
|
MST_ATTR_NONE = 0x2000,
|
|
MSG_ATTR_MAX_NUMBER,
|
|
MSG_ATTR_KEEPALIVE_TIME,
|
|
MSG_ATTR_PROCESS_TIME,
|
|
MST_ATTR_BUTT
|
|
} MSG_ATTR_E;
|
|
|
|
void * msg_create(char * dst_name, char * src_name, PROCESS_CB process_cb, EVENT_CB event_cb, LOG_CB log_cb, void * user_data);
|
|
int msg_destroy(void * handle);
|
|
int msg_post(void * handle, char * dst_name, int cmd, unsigned char * pbuf, int size, int timeout);
|
|
int msg_send(void * handle, char * dst_name, int cmd, unsigned char * pbuf, int size, unsigned char * ret_buf, int max_size, int timeout);
|
|
int msg_set_attr(void * handle, MSG_ATTR_E attr_type, unsigned char * p_attr, int size);
|
|
int msg_get_attr(void * handle, MSG_ATTR_E attr_type, unsigned char * p_attr, int max_size);
|
|
int msg_response(void * client, unsigned char * pbuf, int size);
|
|
|
|
// msg util
|
|
char * msg_util_get_client_name(void * client);
|
|
void * msg_util_get_handle(void * client);
|
|
char * msg_util_get_event_str(int event);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* THIRDLIBS_COMMON_MSG_UTIL_H_ */
|