Package com.pusher.rest
Class Pusher
- All Implemented Interfaces:
AutoCloseable
A library for interacting with the Pusher HTTP API.
See http://github.com/pusher/pusher-http-java for an overview
Essentially:
// Init Pusher pusher = new Pusher(APP_ID, KEY, SECRET); // Publish Result triggerResult = pusher.trigger("my-channel", "my-eventname", myPojoForSerialisation); if (triggerResult.getStatus() != Status.SUCCESS) { if (triggerResult.getStatus().shouldRetry()) { // Temporary, let's schedule a retry } else { // Something is wrong with our request } } // Query Result channelListResult = pusher.get("/channels"); if (channelListResult.getStatus() == Status.SUCCESS) { String channelListAsJson = channelListResult.getMessage(); // etc }See
PusherAsync
for the asynchronous implementation.-
Field Summary
Fields inherited from class com.pusher.rest.PusherAbstract
appId, BODY_SERIALISER, host, key, scheme, secret
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an instance of the Pusher object through which you may interact with the Pusher API.Construct an instance of the Pusher object through which you may interact with the Pusher API. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
configureHttpClient
(org.apache.http.impl.client.HttpClientBuilder builder) Configure the HttpClient instance which will be used for making calls to the Pusher API.static org.apache.http.impl.client.HttpClientBuilder
Returns an HttpClientBuilder with the settings used by default applied.protected Result
protected Result
void
setRequestTimeout
(int requestTimeout) Default: 4000Methods inherited from class com.pusher.rest.PusherAbstract
authenticate, authenticate, get, get, post, serialise, setCluster, setCryptoUtil, setDataMarshaller, setEncrypted, setGsonSerialiser, setHost, signedUri, signedUri, trigger, trigger, trigger, trigger, trigger, validateWebhookSignature
-
Constructor Details
-
Pusher
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.
-
Pusher
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.encryptionMasterKeyBase64
- 32 byte key, base64 encoded. This key, along with the channel name, are used to derive per-channel encryption keys.
-
Pusher
-
-
Method Details
-
setRequestTimeout
Default: 4000- Parameters:
requestTimeout
- the request timeout in milliseconds
-
defaultHttpClientBuilder
Returns an HttpClientBuilder with the settings used by default applied. You may apply further configuration (for example an HTTP proxy), override existing configuration (for example, the connection manager which handles connection pooling for reuse) and then callconfigureHttpClient(HttpClientBuilder)
to have this configuration applied to all subsequent calls.- Returns:
- an
HttpClientBuilder
with the default settings applied - See Also:
-
configureHttpClient
Configure the HttpClient 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
defaultHttpClientBuilder()
as a base, apply your custom config to that and then pass the builder in here, to ensure that sensible defaults for configuration areas you are not setting explicitly are retained.e.g.
pusher.configureHttpClient( Pusher.defaultHttpClientBuilder() .setProxy(new HttpHost("proxy.example.com")) .disableAutomaticRetries() );
- Parameters:
builder
- anHttpClientBuilder
with which to configure the internal HTTP client- See Also:
-
doGet
- Specified by:
doGet
in classPusherAbstract<Result>
-
doPost
- Specified by:
doPost
in classPusherAbstract<Result>
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-