0

我正在尝试使用 Stomp-php ( https://github.com/stomp-php/stomp-php ) 从 Kontakt.io API ( https://developer.kontakt.io/backend/le/获取数据监控/)但我正在为经纪人部分苦苦挣扎。一些文档谈到使用带有 stomp 的代理(如 activeMQ)来使其工作,但我真的不明白为什么。

通过在我的前端使用 stomp,就不需要这样的东西了。

知道这是如何工作的吗?谢谢

以防万一,我的代码:

    // make a connection
    $stomp = new Stomp\StatefulStomp(
        new Stomp\Client('wss://ovs.kontakt.io:9090/stream?apiKey=key')
    );

    // send a message to the queue
    //$message =  new Stomp\Transport\Message(null, array('api-key','key'));

    // subscribe to the queue
    $stomp->subscribe('/presence/stream/gw');

    // receive a message from the queue
    $msg = $stomp->read();
    // do what you want with the message
    if ($msg != null) {
        echo "Received message with body '$msg->body'\n";
        // mark the message as received in the queue
        $stomp->ack($msg);
    } else {
        echo "Failed to receive a message\n";
    }
    $stomp->unsubscribe();
4

1 回答 1

0

大多数关于 STOMP 的文档都会提到代理,因为在大多数情况下,代理负责从/向客户端接收和发送消息。我对 Kontact.io 不是很熟悉,但阅读您链接的文档表明 Kontact.io 本身在您的用例中充当“经纪人”。STOMP 客户端正在连接到 Kontact.io 服务公开的端点。

于 2018-08-29T15:54:06.307 回答