1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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 FileApi = extern "C" fn(service_id: i64, request_id: i64, file_name: *const u8, len: u32);
//
pub type WriteApi = extern "C" fn(
    service_id: i64,
    request_id: i64,
    file_name: *const u8,
    len: u32,
    content: *const u8,
    content_len: u32,
);

//

pub type GenIDApi = extern "C" fn(service_id: i64) -> i64;
pub type ResponseApi = extern "C" fn(service_id: i64, request_id: i64, msg: *const u8, len: u32);
//
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 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 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 GetConnectionApi = extern "C" fn(service_id: i64, request_id: i64);

// 放回链接
pub type PutbackConnectionApi = extern "C" fn(service_id: i64, request_id: i64);

// 开启事务
pub type BeginTxApi = extern "C" fn(service_id: i64, request_id: i64);

// 回滚事务
pub type RollbackApi = extern "C" fn(service_id: i64, request_id: i64);

// 提交事务
pub type CommitApi = extern "C" fn(service_id: i64, request_id: i64);

// 查询事务
pub type QueryApi = extern "C" fn(service_id: i64, request_id: i64, sql: *const u8, len: u32);

// 查询事务
pub type ExecuteApi = extern "C" fn(service_id: i64, request_id: i64, sql: *const u8, len: u32);

// 查询事务
pub type IsTableExistApi =
    extern "C" fn(service_id: i64, request_id: i64, sql: *const u8, len: u32);
/**
 *
 *
 */
pub type SubscribeHandler = extern "C" fn(u16, 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);