Package com.pusher.rest
Class PusherAsync
- All Implemented Interfaces:
AutoCloseable
A library for interacting with the Pusher HTTP API asynchronously.
See http://github.com/pusher/pusher-http-java for an overview
Essentially:
// Init
PusherAsync pusher = new PusherAsync(APP_ID, KEY, SECRET);
// Publish
CompletableFuture<Result> futureTriggerResult = pusher.trigger("my-channel", "my-eventname", myPojoForSerialisation);
triggerResult.thenAccept(triggerResult -> {
if (triggerResult.getStatus() == Status.SUCCESS) {
// request was successful
} else {
// something went wrong with the request
}
});
// Query
CompletableFuture<Result> futureChannelListResult = pusher.get("/channels");
futureChannelListResult.thenAccept(triggerResult -> {
if (triggerResult.getStatus() == Status.SUCCESS) {
String channelListAsJson = channelListResult.getMessage();
// etc.
} else {
// something went wrong with the request
}
});
See Pusher for the synchronous implementation.-
Field Summary
Fields inherited from class com.pusher.rest.PusherAbstract
appId, BODY_SERIALISER, host, key, scheme, secret -
Constructor Summary
ConstructorsConstructorDescriptionPusherAsync(String url) PusherAsync(String appId, String key, String secret) Construct an instance of the Pusher object through which you may interact with the Pusher API. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidconfigureHttpClient(org.asynchttpclient.DefaultAsyncHttpClientConfig.Builder builder) Configure the AsyncHttpClient instance which will be used for making calls to the Pusher API.protected CompletableFuture<Result>protected CompletableFuture<Result>Methods inherited from class com.pusher.rest.PusherAbstract
authenticate, authenticate, get, get, post, serialise, setCluster, setDataMarshaller, setEncrypted, setGsonSerialiser, setHost, signedUri, signedUri, trigger, trigger, trigger, trigger, trigger, validateWebhookSignature
-
Constructor Details
-
PusherAsync
Construct an instance of the Pusher object through which you may interact with the Pusher API.The parameters to use are found on your dashboard at https://app.pusher.com and are specific per App.
- Parameters:
appId- The ID of the App you will to interact with.key- The App Key, the same key you give to websocket clients to identify your app when they connect to Pusher.secret- The App Secret. Used to sign requests to the API, this should be treated as sensitive and not distributed.
-
PusherAsync
-
-
Method Details
-
configureHttpClient
Configure the AsyncHttpClient instance which will be used for making calls to the Pusher API.This method allows almost complete control over all aspects of the HTTP client, including
- proxy host
- connection pooling and reuse strategies
- automatic retry and backoff strategies
e.g.
pusher.configureHttpClient( config() .setProxyServer(proxyServer("127.0.0.1", 38080)) .setMaxRequestRetry(5) );- Parameters:
builder- anDefaultAsyncHttpClientConfig.Builderwith which to configure the internal HTTP client
-
doGet
- Specified by:
doGetin classPusherAbstract<CompletableFuture<Result>>
-
doPost
- Specified by:
doPostin classPusherAbstract<CompletableFuture<Result>>
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-