summaryrefslogtreecommitdiffstats
path: root/extra/push-examples/java/index.java
diff options
context:
space:
mode:
Diffstat (limited to 'extra/push-examples/java/index.java')
-rw-r--r--extra/push-examples/java/index.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/extra/push-examples/java/index.java b/extra/push-examples/java/index.java
new file mode 100644
index 0000000..5a77342
--- /dev/null
+++ b/extra/push-examples/java/index.java
@@ -0,0 +1,32 @@
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * Compile: javac index.java
+ * Run: java Index
+ */
+class Index {
+
+ public static final String PUSH_URL = "https://example.com/api/push/key?status=up&msg=OK&ping=";
+ public static final int INTERVAL = 60;
+
+ public static void main(String[] args) {
+ while (true) {
+ try {
+ URL url = new URL(PUSH_URL);
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ con.setRequestMethod("GET");
+ con.getResponseCode();
+ con.disconnect();
+ System.out.println("Pushed!");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ try {
+ Thread.sleep(INTERVAL * 1000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}