Package com.launchdarkly.eventsource
Class ConnectStrategy.Client
- java.lang.Object
-
- com.launchdarkly.eventsource.ConnectStrategy.Client
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Enclosing class:
- ConnectStrategy
public abstract static class ConnectStrategy.Client extends java.lang.Object implements java.io.Closeable
An object provided byConnectStrategy
that is retained by a singleEventSource
instance to perform all connection attempts by that instance.For the default HTTP implementation, this represents a configured HTTP client.
The
Closeable.close()
method should be implemented to do any necessary cleanup when an EventSource instance is being permanently disposed of.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConnectStrategy.Client.Result
The return type ofconnect(String)
.
-
Constructor Summary
Constructors Constructor Description Client()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract boolean
awaitClosed(long timeoutMillis)
abstract ConnectStrategy.Client.Result
connect(java.lang.String lastEventId)
Attempts to connect to a stream.abstract java.net.URI
getOrigin()
Returns the expected URI of the stream.
-
-
-
Method Detail
-
connect
public abstract ConnectStrategy.Client.Result connect(java.lang.String lastEventId) throws StreamException
Attempts to connect to a stream.- Parameters:
lastEventId
- the current value ofEventSource.getLastEventId()
(should be sent to the server to support resuming an interrupted stream)- Returns:
- the result if successful
- Throws:
StreamException
- if not successful
-
awaitClosed
public abstract boolean awaitClosed(long timeoutMillis) throws java.lang.InterruptedException
- Parameters:
timeoutMillis
- maximum amount of time to wait- Returns:
- true if all requests are now closed
- Throws:
java.lang.InterruptedException
- if the thread is interrupted
-
getOrigin
public abstract java.net.URI getOrigin()
Returns the expected URI of the stream.This value is returned by
EventSource.getOrigin()
. It can be overridden on a per-connection basis withConnectStrategy.Client.Result.getOrigin()
.- Returns:
- the stream URI
-
-