xrtSshChannelsConfigInit

写入适合交互会话和并发客户端的有界默认配置。

void xrtSshChannelsConfigInit(xsshchannelsconfig* pConfig);
参数说明
xsshchannelsconfig* pConfig配置结构
返回:写入适合交互会话和并发客户端的有界默认配置。

示例已编译验证

sshchannelsconfiginit obj;
xrtSshChannelsConfigInit(&obj);

xrtSshChannelsInit

初始化空集合;缓冲池只借用,空指针使用 XRT 默认网络缓冲池。

bool xrtSshChannelsInit( xsshchannels* pChannels, xnetbufpool* pPool, const xsshchannelsconfig* pConfig );
参数说明
xsshchannels* pChannelsChannels 参数
xnetbufpool* pPool池
const xsshchannelsconfig* pConfig配置结构
返回:初始化空集合;缓冲池只借用,空指针使用 XRT 默认网络缓冲池。

示例已编译验证

sshchannelsinit obj;
xrtSshChannelsInit(&obj, pChannels, pPool);

xrtSshChannelsClear

释放全部 channel、动态数据和回复 token,不释放借用缓冲池。

void xrtSshChannelsClear(xsshchannels* pChannels);
参数说明
xsshchannels* pChannelsChannels 参数
返回:释放全部 channel、动态数据和回复 token,不释放借用缓冲池。

示例已编译验证

/* 释放全部 channel、动态数据和回复 token,不释放借用缓冲池。 */
result = xrtSshChannelsClear(pChannels);

xrtSshChannelsCount

返回当前活动 channel 数量;无效集合返回零。

size_t xrtSshChannelsCount(const xsshchannels* pChannels);
参数说明
const xsshchannels* pChannelsChannels 参数
返回:返回当前活动 channel 数量;无效集合返回零。

示例已编译验证

/* 返回当前活动 channel 数量;无效集合返回零。 */
result = xrtSshChannelsCount(pChannels);

xrtSshChannelsOpen

创建等待 peer confirmation 的本端 channel,并返回稳定借用地址。

xsshcode xrtSshChannelsOpen( xsshchannels* pChannels, xsshchannel** ppChannel );
参数说明
xsshchannels* pChannelsChannels 参数
xsshchannel** ppChannel通道对象
返回:创建等待 peer confirmation 的本端 channel,并返回稳定借用地址。

示例已编译验证

/* 创建等待 peer confirmation 的本端 channel,并返回稳定借用地址。 */
result = xrtSshChannelsOpen(pChannels, ppChannel);

xrtSshChannelsAccept

为一条 peer CHANNEL_OPEN 创建等待本端决定的动态 channel。

xsshcode xrtSshChannelsAccept( xsshchannels* pChannels, const xsshchannelopen* pOpen, xsshchannel** ppChannel );
参数说明
xsshchannels* pChannelsChannels 参数
const xsshchannelopen* pOpenOen 参数
xsshchannel** ppChannel通道对象
返回:为一条 peer CHANNEL_OPEN 创建等待本端决定的动态 channel。

示例已编译验证

/* 为一条 peer CHANNEL_OPEN 创建等待本端决定的动态 channel。 */
result = xrtSshChannelsAccept(pChannels, pOpen, ppChannel);

xrtSshChannelsGet

按本端 channel id 返回稳定借用地址;未找到是正常结果。

xsshchannel* xrtSshChannelsGet( xsshchannels* pChannels, uint32 iLocal );
参数说明
xsshchannels* pChannelsChannels 参数
uint32 iLocalLocal 参数
返回:按本端 channel id 返回稳定借用地址;未找到是正常结果。

示例已编译验证

/* 按本端 channel id 返回稳定借用地址;未找到是正常结果。 */
result = xrtSshChannelsGet(pChannels, iLocal);

xrtSshChannelsConstGet

返回只读 channel;未找到是正常结果。

const xsshchannel* xrtSshChannelsConstGet( const xsshchannels* pChannels, uint32 iLocal );
参数说明
const xsshchannels* pChannelsChannels 参数
uint32 iLocalLocal 参数
返回:返回只读 channel;未找到是正常结果。

示例已编译验证

/* 返回只读 channel;未找到是正常结果。 */
result = xrtSshChannelsConstGet(pChannels, iLocal);

xrtSshChannelReplyReserve

为 want-reply 请求按需扩展 token 存储,已有 token 顺序保持不变。

xsshcode xrtSshChannelReplyReserve( xsshchannel* pChannel, size_t iCapacity );
参数说明
xsshchannel* pChannel通道对象
size_t iCapacity容量
返回:为 want-reply 请求按需扩展 token 存储,已有 token 顺序保持不变。

示例已编译验证

/* 为 want-reply 请求按需扩展 token 存储,已有 token 顺序保持不变。 */
result = xrtSshChannelReplyReserve(pChannel, iCapacity);

xrtSshChannelsRemove

删除已经结束且没有未消费数据或回复的 channel。

bool xrtSshChannelsRemove( xsshchannels* pChannels, uint32 iLocal );
参数说明
xsshchannels* pChannelsChannels 参数
uint32 iLocalLocal 参数
返回:删除已经结束且没有未消费数据或回复的 channel。

示例已编译验证

/* 删除已经结束且没有未消费数据或回复的 channel。 */
result = xrtSshChannelsRemove(pChannels, iLocal);

xrtSshChannelsDiscard

强制丢弃指定 channel 及其全部排队数据,供连接关闭和策略拒绝使用。

bool xrtSshChannelsDiscard( xsshchannels* pChannels, uint32 iLocal );
参数说明
xsshchannels* pChannelsChannels 参数
uint32 iLocalLocal 参数
返回:强制丢弃指定 channel 及其全部排队数据,供连接关闭和策略拒绝使用。

示例已编译验证

/* 强制丢弃指定 channel 及其全部排队数据,供连接关闭和策略拒绝使用。 */
result = xrtSshChannelsDiscard(pChannels, iLocal);

xrtSshChannelsResolve

直接适配 xsshchannelresolveproc,UserData 必须指向活动集合。

bool xrtSshChannelsResolve( ptr pUserData, uint32 iLocal, xsshchannelcore** ppChannel, xsshreplyqueue** ppReplies );
参数说明
ptr pUserData透传用户数据
uint32 iLocalLocal 参数
xsshchannelcore** ppChannel通道对象
xsshreplyqueue** ppRepliesReles 参数
返回:直接适配 xsshchannelresolveproc,UserData 必须指向活动集合。

示例已编译验证

/* 直接适配 xsshchannelresolveproc,UserData 必须指向活动集合。 */
result = xrtSshChannelsResolve(pUserData, iLocal, ppChannel, ppReplies);

xrtSshChannelsIterBegin

启动按本端 channel id 递增的外置迭代。

bool xrtSshChannelsIterBegin( xsshchannels* pChannels, xsshchannelsiter* pIterator );
参数说明
xsshchannels* pChannelsChannels 参数
xsshchannelsiter* pIterator迭代器
返回:启动按本端 channel id 递增的外置迭代。

示例已编译验证

/* 启动按本端 channel id 递增的外置迭代。 */
result = xrtSshChannelsIterBegin(pChannels, pIterator);

xrtSshChannelsIterNext

返回下一活动 channel,并可选返回本端 id。

xsshchannel* xrtSshChannelsIterNext( xsshchannelsiter* pIterator, uint32* pLocal );
参数说明
xsshchannelsiter* pIterator迭代器
uint32* pLocal本地地址
返回:返回下一活动 channel,并可选返回本端 id。

示例已编译验证

/* 返回下一活动 channel,并可选返回本端 id。 */
result = xrtSshChannelsIterNext(pIterator, pLocal);

xrtSshChannelsIterEnd

提前结束迭代并释放结构修改保护。

void xrtSshChannelsIterEnd(xsshchannelsiter* pIterator);
参数说明
xsshchannelsiter* pIterator迭代器
返回:提前结束迭代并释放结构修改保护。

示例已编译验证

/* 提前结束迭代并释放结构修改保护。 */
result = xrtSshChannelsIterEnd(pIterator);

xrtSshChannelsOnRemoved

设置唯一删除观察器;成功删除后同步报告本端 id,空回调可取消观察。

XRT_API bool xrtSshChannelsOnRemoved( xsshchannels* pChannels, xsshchannelsremovedproc pRemoved, ptr pUserData );
参数说明
xsshchannels* pChannels通道集合
xsshchannelsremovedproc pRemoved删除回调;传 NULL 取消
ptr pUserData透传用户数据
返回:设置成功返回 true。观察器只接收已经失效的本端 id,不借用已释放 channel。

示例已编译验证

static void on_removed(xsshchannels* p, uint32 local, ptr user) {
    (void)p; (void)user;
    printf("removed=%u\n", (unsigned)local);
}

xsshchannelsconfig cfg;
xrtSshChannelsConfigInit(&cfg);
xsshchannels ch;
xrtSshChannelsInit(&ch, NULL, &cfg);
printf("set=%d\n", xrtSshChannelsOnRemoved(&ch, on_removed, NULL) ? 1 : 0);
xrtSshChannelsClear(&ch);
输出set=1