Skip to content

Commit 56b96fe

Browse files
author
piotr.kazmierczak
committed
Step 3 - Install Ably
1 parent 2ca8a5b commit 56b96fe

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ repositories {
66
}
77

88
dependencies {
9+
compile 'io.ably:ably-java:0.8.+'
910
}
10-
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.ably.tutorial;
2+
3+
import io.ably.lib.rest.AblyRest;
4+
import io.ably.lib.types.AblyException;
5+
6+
public class Example {
7+
8+
private final static String API_KEY = "INSERT-YOUR-API-KEY-HERE"; /* Sign up at ably.io to get your API key */
9+
10+
/* RuntimeException will be thrown if API_KEY will not be set to a proper one */
11+
static {
12+
if (API_KEY.contains("INSERT")) {
13+
throw new RuntimeException("API key is not set, sign up on ably.io to get yours");
14+
}
15+
}
16+
17+
public static void main(String[] args) {
18+
try {
19+
initAbly();
20+
} catch (AblyException e) {
21+
e.printStackTrace();
22+
}
23+
}
24+
25+
/* Add AblyException to method signature as AblyRest constructor can throw one */
26+
private static void initAbly() throws AblyException{
27+
AblyRest ablyRest = new AblyRest(API_KEY);
28+
}
29+
}

0 commit comments

Comments
 (0)