0

我正在关注本教程: https ://sdkdocs.roku.com/display/sdkdoc/External+Control+API ...试图通过 ssdp / http get 获取设备列表。

        let query: string = "M-SEARCH * HTTP/1.1\r\n" +
            "HOST: 239.255.255.250:1900\r\n" +
            "MAN: \"ssdp:discover\"\r\n" +
            "ST: roku: ecp\r\n\r\n";

        this.http
            .get(query)
            .map(res => res.json())
            .subscribe(
            (data) => this.devices = data,
            (err) => this.error = err);

...但我收到 404 错误(另外,localhost 被附加到字符串中):

Failed to load resource: the server responded with a status of 404 (Not Found)

http://localhost:52125/M-SEARCH%20*%20HTTP/1.1HOST:%20239.255.255.250:1900MAN:%20%22ssdp:discover%22ST:%20roku:%20ecp

4

1 回答 1

1

SSDP 使用 HTTPU 或 HTTP over UDP。Node 的 HTTP 客户端只通过 TCP 发送数据。您需要使用 udp 套接字手动发送并监听数据,或使用预先存在的库,例如node-ssdp.

于 2018-02-11T21:37:12.100 回答