Skip to content

获取主题订阅总数 - PubSubGetTopicSubCount

函数简介

获取某个主题当前订阅总数(服务端语义)。

接口名称

PubSubGetTopicSubCount

DLL调用

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 侧可能返回不支持错误。