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/RpcHandler.java | |
parent | 85a93de08694f25bd049c5236f11f06b8d8e4ff7 (diff) |
Rename projects.
– jsonrpc → same
– master → same-android
Diffstat (limited to 'jsonrpc/src/main/java/com/orbekk/rpc/RpcHandler.java')
-rw-r--r-- | jsonrpc/src/main/java/com/orbekk/rpc/RpcHandler.java | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/jsonrpc/src/main/java/com/orbekk/rpc/RpcHandler.java b/jsonrpc/src/main/java/com/orbekk/rpc/RpcHandler.java deleted file mode 100644 index 0bafad4..0000000 --- a/jsonrpc/src/main/java/com/orbekk/rpc/RpcHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.orbekk.rpc; - -import com.googlecode.jsonrpc4j.JsonRpcServer; -import com.orbekk.net.HttpUtil; -import com.orbekk.same.UrlReceiver; -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.handler.AbstractHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RpcHandler extends AbstractHandler { - private Logger logger = LoggerFactory.getLogger(getClass()); - private JsonRpcServer rpcServer; - private UrlReceiver urlReceiver; - - public RpcHandler(JsonRpcServer rpcServer, - UrlReceiver urlReceiver) { - this.rpcServer = rpcServer; - this.urlReceiver = urlReceiver; - } - - @Override - public synchronized void handle(String target, Request baseRequest, - HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.info("Handling request to target: " + target); - - if (urlReceiver != null) { - String sameServiceUrl = "http://" + request.getLocalAddr() + - ":" + request.getLocalPort() + "/SameService.json"; - urlReceiver.setUrl(sameServiceUrl); - urlReceiver = null; - } - - if (target.equals("/ping")) { - int remotePort = Integer.parseInt(request.getParameter("port")); - String pongUrl = "http://" + request.getRemoteAddr() + ":" + - remotePort + "/pong"; - logger.info("Got ping. Sending pong to {}", pongUrl); - HttpUtil.sendHttpRequest(pongUrl); - } else if (target.equals("/pong")) { - logger.info("Received pong from {}", request.getRemoteAddr()); - } else { - rpcServer.handle(request, response); - } - baseRequest.setHandled(true); - } -} |