0

What do I put in for Uri? I am using an EventSource for android a git

private void connect() {
    Thread eventThread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                eventSource = new EventSource(Uri, new SSEHandler(), extraHeaderParameters, true);
                eventSource.connect();
            } catch(URISyntaxException e) {
                Log.v("Error starting eventsource", "True");
            }
        }
    });
    eventThread.start();

}
Emzor
  • 1,380
  • 17
  • 28
eli
  • 335
  • 1
  • 3
  • 18
  • How about a server URL? Like "http://localhost:9292/" – Tapani Feb 18 '16 at 07:45
  • I tried that eventSource = new EventSource(("local.host"), new SSEHandler(), extraHeaderParameters, true); – eli Feb 18 '16 at 07:52
  • it did not work, it cannot resolve the constructor – eli Feb 18 '16 at 07:52
  • If you look at the class you can see that it has a constructor, which takes an URL object. So use: URL("http://whatever"). – Tapani Feb 18 '16 at 07:59
  • URL("local.host"), new SSEHandler(), extraHeaderParameters, true – eli Feb 18 '16 at 08:01
  • I tried that it says method call expected then I added new and it says cannot resolve constructor – eli Feb 18 '16 at 08:01
  • new URL("localhost") – Tapani Feb 18 '16 at 08:02
  • Ya, I tried that and then it says it cannot resolve constructor – eli Feb 18 '16 at 08:02
  • Why don't you check what kind of constructors the EventSource has and just give the right parameters. – Tapani Feb 18 '16 at 08:03
  • Well then we get back to the question of what a Uri is because I checked the parameters and they are this(URI.create(uri), sslEngineFactory, eventSourceHandler, exposeComments); – eli Feb 18 '16 at 08:04
  • As Java documentation says: "A URI is a uniform resource identifier while a URL is a uniform resource locator. Hence every URL is a URI, abstractly speaking, but not every URI is a URL". It has the same constructor as URL: URI(String str). – Tapani Feb 18 '16 at 08:09
  • so the constructor is URI(String "value")? – eli Feb 18 '16 at 08:41

0 Answers0