#include "bus_server_socket_wrapper.h"
|
#include "key_def.h"
|
static Logger *logger = LoggerFactory::getLogger();
|
|
|
/**
|
* 创建
|
*/
|
void * bus_server_socket_wrapper_open() {
|
BusServerSocket *sockt = new BusServerSocket;
|
return (void *)sockt;
|
}
|
|
/**
|
* 关闭
|
*/
|
void bus_server_socket_wrapper_close(void *_socket) {
|
|
BusServerSocket *sockt = (BusServerSocket *)_socket;
|
delete sockt;
|
}
|
|
int bus_server_socket_wrapper_stop(void *_socket) {
|
BusServerSocket *sockt = (BusServerSocket *)_socket;
|
return sockt->stop();
|
}
|
/**
|
* 启动bus
|
*
|
* @return 0 成功, 其他值 失败的错误码
|
*/
|
int bus_server_socket_wrapper_start_bus(void * _socket) {
|
int ret;
|
BusServerSocket *sockt = (BusServerSocket *)_socket;
|
|
if( (ret = sockt->bind(SHM_BUS_KEY)) == 0) {
|
return sockt->start();
|
} else {
|
logger->error("start bus failed");
|
return -1;
|
}
|
|
}
|
|
int bus_server_socket_wrapper_data_get(void * _socket, int val) {
|
int ret;
|
BusServerSocket *sockt = (BusServerSocket *)_socket;
|
|
ret = sockt->get_data(val);
|
|
return ret;
|
|
}
|
|
int bus_server_socket_wrapper_proc_check(void * _socket, int val, char *buf, int len, void **buf_ret, int *len_ret, \
|
const struct timespec *timeout, const int flag) {
|
int ret;
|
BusServerSocket *sockt = (BusServerSocket *)_socket;
|
|
ret = sockt->check_proc(val, buf, len, buf_ret, len_ret, timeout, flag);
|
|
return ret;
|
|
}
|
|
void bus_server_socket_wrapper_proc_release(void * _socket, int val) {
|
|
BusServerSocket *sockt = (BusServerSocket *)_socket;
|
|
sockt->remove_proc(val);
|
|
}
|