diff --git a/Tutorial/app/build.gradle b/Tutorial/app/build.gradle index 5ba841d9..fa2aeb75 100644 --- a/Tutorial/app/build.gradle +++ b/Tutorial/app/build.gradle @@ -22,4 +22,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:24.2.1' + /* add latest version of ably.io client library */ + compile 'io.ably:ably-android:0.8.+' + /* add Volley library for simple network requests */ + compile 'com.android.volley:volley:1.0.0' } diff --git a/Tutorial/app/src/main/AndroidManifest.xml b/Tutorial/app/src/main/AndroidManifest.xml index 7d1e212d..96ebd90f 100644 --- a/Tutorial/app/src/main/AndroidManifest.xml +++ b/Tutorial/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + future = RequestFuture.newFuture(); + /* 10.0.2.2 is the IP address of localhost seen from emulator's perspective */ + String url = "http://10.0.2.2:3000/auth"; + StringRequest request = new StringRequest(url, future, future); + queue.add(request); + try { + /* return response from server with timeout set to 3 seconds */ + return future.get(3, TimeUnit.SECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + } + return null; + } + } diff --git a/Tutorial/build.gradle b/Tutorial/build.gradle index 62311a9e..c20bca14 100644 --- a/Tutorial/build.gradle +++ b/Tutorial/build.gradle @@ -15,8 +15,6 @@ buildscript { allprojects { repositories { jcenter() - /* add following repo for sub-dependency on all your modules */ - maven { url "https://raw.github.com/paddybyers/Java-WebSocket/mvn-repo/" } } } diff --git a/server.js b/server.js index 229f8a37..8ed465eb 100644 --- a/server.js +++ b/server.js @@ -10,9 +10,8 @@ var rest = new Ably.Rest({ key: ApiKey }); const express = require('express'), app = express(); -app.get('/', function (req, res) { - res.send('Hello, I am a very simple server'); -}); +/* Server static content from the root path to keep things simple */ +app.use('/', express.static(__dirname)); /* Issue token requests to clients sending a request to the /auth endpoint */