主题
获取主题订阅总数 - PubSubGetTopicSubCount
函数简介
获取某个主题当前订阅总数(服务端语义)。
接口名称
PubSubGetTopicSubCountDLL调用
c
int32_t PubSubGetTopicSubCount(int64_t instance, char* topic);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLA 实例句柄。 |
| topic | 字符串 | 主题名。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 建议由 Server 侧调用
int count = ola.PubSubGetTopicSubCount("topic/demo");csharp
using OLAPlug;
var ola = new OLAPlugServer();
int count = ola.PubSubGetTopicSubCount("topic/demo");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
count = ola.PubSubGetTopicSubCount("topic/demo")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
ola.PubSubGetTopicSubCount("topic/demo");cpp
var ola = com("OlaPlug.OlaSoft")
ola.PubSubGetTopicSubCount("topic/demo");vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.PubSubGetTopicSubCount("topic/demo");text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.PubSubGetTopicSubCount("topic/demo");aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.PubSubGetTopicSubCount("topic/demo");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.PubSubGetTopicSubCount("topic/demo");cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
ola.PubSubGetTopicSubCount("topic/demo");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
PubSubGetTopicSubCount(instance, "topic/demo");csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int PubSubGetTopicSubCount(long ola, string topic);
long instance = CreateCOLAPlugInterFace();
int count = PubSubGetTopicSubCount(instance, "topic/demo");python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
PubSubGetTopicSubCount(instance, "topic/demo");返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 大于等于 0 为订阅数量;小于 0 为错误码。 |
注意事项
| 项目 | 说明 |
|---|---|
| 推荐由 Server 侧调用 | 推荐由 Server 侧调用,Client 侧可能返回不支持错误。 |
