x-common-lib 0.1.8

DXMesh rust dxc develop library
Documentation
pub mod event {

    // 通道连接事件
    pub const CHANNEL_CONNECTED: u16 = 1;
    // 通道断开事件
    pub const CHANNEL_DISCONNECTED: u16 = 2;
    // 本地服务上线事件
    pub const LOCAL_SERVICE_ON: u16 = 3;
    // 本地服务下线事件
    pub const LOCAL_SERVICE_OFF: u16 = 4;
    // 接收消息,进入airport 之前
    pub const MESSAGE_IN: u16 = 5;
}

// 注入 API
pub type SendMessageApi = extern "C" fn(
    service_id: i64,
    request_id: i64,
    receiver_service_key: *const u8,
    receiver_service_key_len: u32,
    channel_id: i64,
    buffer: *const u8,
    buffer_size: u32,
);
//
pub type SleepApi = extern "C" fn(service_id: i64, request_id: i64, milliseconds: u64);
//
pub type ResponseApi = extern "C" fn(service_id: i64, request_id: i64, msg: *const u8, len: u32);
//
pub type EventResponseApi = extern "C" fn(publish_id: i64, msg: *const u8, len: u32);

pub type GenIDApi = extern "C" fn(service_id: i64) -> i64;
// 

//
pub type OutputLogApi = extern "C" fn(service_id: i64, msg: *const u8, len: u32);

//
pub type LoadServiceApi = extern "C" fn(service_id: i64, request_id: i64, msg: *const u8, len: u32);

pub type UnLoadServiceApi =
    extern "C" fn(service_id: i64, request_id: i64, msg: *const u8, len: u32);

pub type HasServiceApi = extern "C" fn(service_id: i64, request_id: i64, msg: *const u8, len: u32);


pub type SendHttpRequestApi =
    extern "C" fn(service_id: i64, request_id: i64, msg: *const u8, len: u32);
//
pub type GetHttpDataApi = extern "C" fn(service_id: i64, request_id: i64);
//
pub type GetHttpListenAddrApi = extern "C" fn(service_id: i64, request_id: i64);

//
pub type RemoveHttpClientApi = extern "C" fn(service_id: i64, request_id: i64);
//
pub type BuildChannelApi = extern "C" fn(service_id: i64, request_id: i64, node_id: i64);

pub type GetAllLocalServiceApi =
    extern "C" fn(service_id: i64, request_id: i64, filter_system: bool);

pub type AddChannelIdToRemoteServicesApi = extern "C" fn(
    service_id: i64,
    request_id: i64,
    channel_id: i64,
    buffer: *const u8,
    buffer_len: u32,
);

pub type RemoveRemoteServiceAllChannelIdApi = extern "C" fn(
    service_id: i64,
    request_id: i64,
    channel_id: i64,
    buffer: *const u8,
    buffer_len: u32,
);

pub type SetChannelXRPCPortApi =
    extern "C" fn(service_id: i64, request_id: i64, channel_id: i64, port: i32);

pub type GetXPRCPortApi = extern "C" fn(service_id: i64, request_id: i64) -> i32;

// 获取所有连接点
pub type GetAllConnIdApi = extern "C" fn(service_id: i64, request_id: i64);

// 获取所有连接点
pub type GetChannelIdByConnIdApi = extern "C" fn(service_id: i64, request_id: i64, conn_id: i64);


/**

 *
 *
 */
pub type SubscribeHandler = extern "C" fn(u16, i64, data: *const u8, length: u32) -> bool;

// 定于这 Api
pub type SubscribeApi = extern "C" fn(event_id: u16, u32, handler: SubscribeHandler) -> i64;

// 定于这 Api
pub type UnSubscribeApi = extern "C" fn(event_id: u16, subscribe_id: i64);