@Override public int hashCode() { int result = notifier != null ? notifier.hashCode() : 0; result = 31 * result + (server != null ? server.hashCode() : 0); result = 31 * result + (details != null ? details.hashCode() : 0); result = 31 * result + (request != null ? request.hashCode() : 0); result = 31 * result + (error != null ? error.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Notice that = (Notice) o; if (notifier != null ? !notifier.equals(that.notifier) : that.notifier != null) return false; if (server != null ? !server.equals(that.server) : that.server != null) return false; if (details != null ? !details.equals(that.details) : that.details != null) return false; if (request != null ? !request.equals(that.request) : that.request != null) return false; return !(error != null ? !error.equals(that.error) : that.error != null); }
@Override public void handleHttpRequest( HttpRequest httpRequest, HttpResponse httpResponse, HttpControl httpControl) throws Exception { if (!"GET".equals(httpRequest.method())) { httpResponse.status(500); httpResponse.end(); return; } JSONObject build = new JSONObject(); build.put("version", seledendroidServer.getServerVersion()); build.put("browserName", "selendroid"); JSONObject os = new JSONObject(); os.put("arch", seledendroidServer.getCpuArch()); os.put("name", seledendroidServer.getOsName()); os.put("version", seledendroidServer.getOsVersion()); JSONObject json = new JSONObject(); json.put("build", build); json.put("os", os); JSONArray devices = null; try { devices = seledendroidServer.getSupportedDevices(); } catch (Exception e) { devices = new JSONArray(); } json.put("supportedDevices", devices); if (apps == null || devices.length() == 0) { try { apps = seledendroidServer.getSupportedApps(); } catch (Exception e) { apps = new JSONArray(); } } json.put("supportedApps", apps); // httpResponse.header("Content-Type", "text/plain"); httpResponse.header("Content-Type", "application/json"); httpResponse.content("{status: 0, value: " + json + "}"); httpResponse.end(); }