diff options
-rw-r--r-- | same-android/pom.xml | 2 | ||||
-rw-r--r-- | same-android/src/main/java/com/orbekk/HelloAndroidActivity.java | 14 | ||||
-rw-r--r-- | same-android/src/main/java/com/orbekk/PingServer.java | 51 |
3 files changed, 6 insertions, 61 deletions
diff --git a/same-android/pom.xml b/same-android/pom.xml index 0af6627..c40a7ba 100644 --- a/same-android/pom.xml +++ b/same-android/pom.xml @@ -62,7 +62,7 @@ <dependency> <groupId>com.orbekk</groupId> - <artifactId>jsonrpc</artifactId> + <artifactId>same</artifactId> <version>0.0-SNAPSHOT</version> </dependency> </dependencies> diff --git a/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java index 4160bf4..653a870 100644 --- a/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java +++ b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java @@ -1,6 +1,7 @@ package com.orbekk; import com.orbekk.net.Broadcaster; +import com.orbekk.same.ClientApp; import android.app.Activity; import android.os.Bundle; @@ -9,8 +10,7 @@ import android.util.Log; public class HelloAndroidActivity extends Activity { private static String TAG = "master"; - private PingServer pingServer; - + /** * Called when the activity is first created. * @param savedInstanceState If the activity is being re-initialized after @@ -27,22 +27,18 @@ public class HelloAndroidActivity extends Activity { Log.i(TAG, "onCreate"); setContentView(R.layout.main); - pingServer = PingServer.createPingServer(10080); - try { - pingServer.start(); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } // Broadcast broadcast = new Broadcast(this); // broadcast.sendBroadcast("Broadcast test".getBytes(), 10010); Broadcaster broadcaster = new Broadcaster(); Log.i(TAG, "Broadcast success: " + broadcaster.sendBroadcast(10010, "Broadcast test from Android".getBytes())); + + ClientApp client = new ClientApp(); + client.run(10015, "ClientNetwork", "http://10.0.0.6:10010/"); } @Override protected void onDestroy() { - pingServer.stop(); super.onDestroy(); } } diff --git a/same-android/src/main/java/com/orbekk/PingServer.java b/same-android/src/main/java/com/orbekk/PingServer.java deleted file mode 100644 index 5df2346..0000000 --- a/same-android/src/main/java/com/orbekk/PingServer.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.orbekk; - -import org.eclipse.jetty.server.Server; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.googlecode.jsonrpc4j.JsonRpcServer; -import com.orbekk.rpc.PingService; -import com.orbekk.rpc.PingServiceImpl; -import com.orbekk.rpc.RpcHandler; - -public class PingServer { - private Server server; - private Logger logger = LoggerFactory.getLogger(getClass()); - - public PingServer(Server server) { - this.server = server; - } - - public static PingServer createPingServer(int port) { - PingService service = new PingServiceImpl(); - JsonRpcServer jsonServer = new JsonRpcServer(service, PingService.class); - - Server server = new Server(port); - RpcHandler rpcHandler = new RpcHandler(jsonServer); - server.setHandler(rpcHandler); - - return new PingServer(server); - } - - public void start() throws Exception { - logger.info("Starting server."); - server.start(); - } - - public void join() { - try { - server.join(); - } catch (InterruptedException e) { - logger.info("Received InterruptException while waiting for server.", e.fillInStackTrace()); - } - } - - public void stop() { - try { - server.stop(); - } catch (Exception e) { - logger.warn("Exception when stopping server.", e.fillInStackTrace()); - } - } -} |