public final class StitchAppClientImpl extends Object implements StitchAppClient, AuthMonitor
Constructor and Description |
---|
StitchAppClientImpl(String clientAppId,
StitchAppClientConfiguration config)
Constructs an app client with the given configuration.
|
Modifier and Type | Method and Description |
---|---|
Task<Void> |
callFunction(String name,
List<?> args)
Calls the specified Stitch function.
|
<ResultT> Task<ResultT> |
callFunction(String name,
List<?> args,
Class<ResultT> resultClass)
Calls the specified Stitch function, and decodes the response into an instance of the specified
type.
|
<ResultT> Task<ResultT> |
callFunction(String name,
List<?> args,
Class<ResultT> resultClass,
CodecRegistry codecRegistry)
Calls the specified Stitch function, and decodes the response into an instance of the specified
type.
|
<ResultT> Task<ResultT> |
callFunction(String name,
List<?> args,
Decoder<ResultT> resultDecoder)
|
Task<Void> |
callFunction(String name,
List<?> args,
Long requestTimeout)
Calls the specified Stitch function.
|
<ResultT> Task<ResultT> |
callFunction(String name,
List<?> args,
Long requestTimeout,
Class<ResultT> resultClass)
Calls the specified Stitch function, and decodes the response into an instance of the specified
type.
|
<ResultT> Task<ResultT> |
callFunction(String name,
List<?> args,
Long requestTimeout,
Class<ResultT> resultClass,
CodecRegistry codecRegistry)
Calls the specified Stitch function, and decodes the response into an instance of the specified
type.
|
<ResultT> Task<ResultT> |
callFunction(String name,
List<?> args,
Long requestTimeout,
Decoder<ResultT> resultDecoder)
|
void |
close()
Closes the client and shuts down all background operations.
|
StitchAuth |
getAuth()
Gets the authentication component of the app.
|
StitchPush |
getPush()
Gets the push notifications component of the app.
|
<T> T |
getServiceClient(NamedServiceClientFactory<T> factory,
String serviceName)
Gets a client for the given named service.
|
<T> T |
getServiceClient(ServiceClientFactory<T> factory)
Gets a client for the given service.
|
StitchServiceClient |
getServiceClient(String serviceName)
Gets a general purpose client for the given named service.
|
boolean |
isLoggedIn() |
public StitchAppClientImpl(String clientAppId, StitchAppClientConfiguration config)
clientAppId
- the client app id for the app.config
- the configuration to use for the app client.public StitchAuth getAuth()
StitchAppClient
getAuth
in interface StitchAppClient
public StitchPush getPush()
StitchAppClient
getPush
in interface StitchAppClient
public <T> T getServiceClient(NamedServiceClientFactory<T> factory, String serviceName)
StitchAppClient
getServiceClient
in interface StitchAppClient
T
- the type of client to be returned by the factory.factory
- the factory that will create a client for the service.serviceName
- the name of the service.public <T> T getServiceClient(ServiceClientFactory<T> factory)
StitchAppClient
getServiceClient
in interface StitchAppClient
T
- the type of client to be returned by the factory.factory
- the factory that will create a client for the service.public StitchServiceClient getServiceClient(String serviceName)
StitchAppClient
getServiceClient
in interface StitchAppClient
serviceName
- the name of the service.public Task<Void> callFunction(String name, List<?> args)
StitchAppClient
callFunction
in interface StitchAppClient
name
- the name of the Stitch function to call.args
- the arguments to pass to the function.Task
that completes when the function call completes.public Task<Void> callFunction(String name, List<?> args, Long requestTimeout)
StitchAppClient
callFunction
in interface StitchAppClient
name
- the name of the Stitch function to call.args
- the arguments to pass to the function.requestTimeout
- the number of milliseconds the client should wait for a response from the
server before failing with an error.Task
containing the decoded value.public <ResultT> Task<ResultT> callFunction(String name, List<?> args, Class<ResultT> resultClass)
StitchAppClient
callFunction
in interface StitchAppClient
ResultT
- the type into which the Stitch response will be decoded.name
- the name of the Stitch function to call.args
- he arguments to pass to the function.resultClass
- the class that the response should be decoded as.Task
containing the decoded value.public <ResultT> Task<ResultT> callFunction(String name, List<?> args, Long requestTimeout, Class<ResultT> resultClass)
StitchAppClient
callFunction
in interface StitchAppClient
ResultT
- the type into which the Stitch response will be decoded.name
- the name of the Stitch function to call.args
- the arguments to pass to the function.requestTimeout
- the number of milliseconds the client should wait for a response from the
server before failing with an error.resultClass
- the class that the response should be decoded as.Task
containing the decoded value.public <ResultT> Task<ResultT> callFunction(String name, List<?> args, Class<ResultT> resultClass, CodecRegistry codecRegistry)
StitchAppClient
callFunction
in interface StitchAppClient
ResultT
- the type into which the Stitch response will be decoded.name
- the name of the Stitch function to call.args
- the arguments to pass to the function.resultClass
- the class that the response should be decoded as.codecRegistry
- the codec registry used for de/serialization of the function call.Task
containing the decoded value.public <ResultT> Task<ResultT> callFunction(String name, List<?> args, Long requestTimeout, Class<ResultT> resultClass, CodecRegistry codecRegistry)
StitchAppClient
callFunction
in interface StitchAppClient
ResultT
- the type into which the Stitch response will be decoded.name
- the name of the Stitch function to call.args
- the arguments to pass to the function.requestTimeout
- the number of milliseconds the client should wait for a response from the
server before failing with an error.resultClass
- the class that the response should be decoded as.codecRegistry
- the codec registry used for de/serialization of the function call.Task
containing the decoded value.public <ResultT> Task<ResultT> callFunction(String name, List<?> args, Decoder<ResultT> resultDecoder)
StitchAppClient
Decoder
or Codec
.callFunction
in interface StitchAppClient
ResultT
- the type into which the response will be decoded.name
- the name of the Stitch function to call.args
- the arguments to pass to the function.resultDecoder
- the Decoder
or Codec
to use to decode the response into a
value.Task
containing the decoded value.public <ResultT> Task<ResultT> callFunction(String name, List<?> args, Long requestTimeout, Decoder<ResultT> resultDecoder)
StitchAppClient
Decoder
or Codec
. Also accepts a timeout in milliseconds. Use this for
functions that may run longer than the client-wide default timeout (15 seconds by default).callFunction
in interface StitchAppClient
ResultT
- the type into which the response will be decoded.name
- the name of the Stitch function to call.args
- the arguments to pass to the function.requestTimeout
- the number of milliseconds the client should wait for a response from the
server before failing with an error.resultDecoder
- the Decoder
or Codec
to use to decode the response into a
value.Task
containing the decoded value.public boolean isLoggedIn()
isLoggedIn
in interface AuthMonitor
public void close() throws IOException
close
in interface StitchAppClient
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if any thread shutdown errors happen.