1

我正在使用 https://github.com/streamdataio/eventsource-android/的 EventSource REPO 并创建了一个 onConnect (); 方法,然而, eventsource.connect();method 带有红色下划线并说我无法访问它,因为它是私有的?我在网上查看,每个人都使用这个 REPO 没有问题,这里发生了什么?

 private void connect() {
    // Create headers: Add the streamdata.io app token
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("X-Sd-Token", streamdataioAppToken);

    // Create the EventSource with API URL & Streamdata.io authentication token
    try {
        eventSource = new EventSource(new URI(streamdataioProxyPrefix), new URI(myApiUrl), new SSEHandler(), headers);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    // Start data receiving
    eventSource.connect();

}
4

1 回答 1

1

我是来自 streamdata.io 的 Lorie。感谢您查看我们的示例项目。事实上,您是第一个报告此类问题的用户。您提供的这段代码似乎没有任何问题。请确保您的 eventSource 对象在您的代码中较早声明为 EventSource 类型,并且您导入了正确的 EventSource 类:tylerjroach.com.eventsource_android.EventSource; 如果您仍然遇到问题,我建议您将代码放在 GitHub 公共存储库上并将链接发送给我们,以便我们帮助您解决此问题。

于 2016-02-17T08:01:14.600 回答