+ * Clients built here are the same {@link AblyRest} and {@link AblyRealtime} objects the core SDK + * has always returned, and behave identically. What the artifact adds is the choice itself: the + * dependency you declare and the factory you call state which side of the connection your code runs + * on, rather than leaving it to be inferred. + *
+ * If your code runs on an end-user device, use the {@code io.ably.pubsub:device} artifact instead. + * + *
{@code
+ * AblyRest http = PubSubServer.httpClientBuilder()
+ * .key("xVLyHw.MHOCLg:...")
+ * .build();
+ *
+ * AblyRealtime realtime = PubSubServer.realtimeClientBuilder()
+ * .key("xVLyHw.MHOCLg:...")
+ * .echoMessages(false)
+ * .build();
+ * }
+ */
+public final class PubSubServer {
+
+ private PubSubServer() {
+ }
+
+ /**
+ * Creates a builder for a stateless HTTP client, which talks to Ably over plain HTTP requests
+ * without holding a connection open.
+ * + * This is the right choice for most server-side work: publishing, reading history, querying + * presence, issuing tokens and push administration. + * + * @return a new builder. + */ + public static HttpClientBuilder httpClientBuilder() { + return new HttpClientBuilder(); + } + + /** + * Creates a builder for a realtime client, which holds a persistent connection to Ably and can + * subscribe to messages and presence as they happen. + *
+ * Choose this over {@link #httpClientBuilder()} only when the server needs to receive messages
+ * live, rather than only send them.
+ *
+ * @return a new builder.
+ */
+ public static RealtimeClientBuilder realtimeClientBuilder() {
+ return new RealtimeClientBuilder();
+ }
+
+ /**
+ * The options common to both server-side clients. One method per {@link ClientOptions}
+ * property that can affect a client of either kind; {@link RealtimeClientBuilder} adds the
+ * properties that only mean something for a persistent connection.
+ *
+ * @param
+ * Deliberately does not expose the realtime-only options, since an {@link AblyRest} never
+ * opens a connection for them to apply to.
+ */
+ public static final class HttpClientBuilder extends ClientBuilder