diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-13 10:18:02 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-13 10:18:02 +0100 |
commit | ba7132f3ce5629cff2cc4857fff7bd672511bee8 (patch) | |
tree | dc6f7d1adafb8351004f2de6f3f775ebfe596fc7 /jsonrpc/src/main/java/com/orbekk/rpc/Client.java | |
parent | 85a93de08694f25bd049c5236f11f06b8d8e4ff7 (diff) |
Rename projects.
– jsonrpc → same
– master → same-android
Diffstat (limited to 'jsonrpc/src/main/java/com/orbekk/rpc/Client.java')
-rw-r--r-- | jsonrpc/src/main/java/com/orbekk/rpc/Client.java | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/jsonrpc/src/main/java/com/orbekk/rpc/Client.java b/jsonrpc/src/main/java/com/orbekk/rpc/Client.java deleted file mode 100644 index 225347a..0000000 --- a/jsonrpc/src/main/java/com/orbekk/rpc/Client.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.orbekk.rpc; - -import com.googlecode.jsonrpc4j.JsonRpcServer; -import com.orbekk.same.ConnectionManagerImpl; -import com.orbekk.same.SameState; -import com.orbekk.same.SameService; -import com.orbekk.same.SameServiceImpl; -import com.orbekk.net.HttpUtil; -import org.eclipse.jetty.server.Server; - -public class Client { - - public static void main(String[] args) { - if (args.length < 4) { - System.err.println("Arguments: port clientId thisNetworkName " + - "remoteNetworkAddr"); - System.exit(1); - } - int port = Integer.parseInt(args[0]); - String clientId = args[1]; - String networkName = args[2]; - String remoteAddr = args[3]; - - ConnectionManagerImpl connections = new ConnectionManagerImpl(); - - SameState sameState = new SameState(networkName, clientId, - connections); - sameState.start(); - - SameServiceImpl service = new SameServiceImpl(sameState); - JsonRpcServer jsonServer = new JsonRpcServer(service, - SameService.class); - - Server server = new Server(port); - RpcHandler rpcHandler = new RpcHandler(jsonServer, sameState); - server.setHandler(rpcHandler); - - try { - server.start(); - } catch (Exception e) { - System.out.println("Could not start jetty server."); - e.printStackTrace(); - } - - while (sameState.getUrl() == null) { - HttpUtil.sendHttpRequest(remoteAddr + "ping?port=" + port); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // Ignore interrupt in wait loop. - } - } - - SameService remoteService = connections.getConnection(remoteAddr); - remoteService.notifyNetwork("NoNetwork"); - remoteService.participateNetwork("FirstNetwork", - sameState.getClientId(), sameState.getUrl()); - - try { - server.join(); - } catch (InterruptedException e) { - System.out.println("Interrupt"); - } - - } -} |