Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
fixes for #38
  • Loading branch information
pmuellr committed Oct 13, 2011
1 parent b2ad995 commit f85a7e2f1f1152fd2e7a9d2ba77de46411ec7a9a
Showing 4 changed files with 49 additions and 49 deletions.
@@ -10,6 +10,4 @@ java \
-Dfile.encoding=UTF-8 \
-classpath $CP \
weinre.server.Main \
--verbose true \
--deathTimeout 120

@@ -1,7 +1,7 @@
/*
* weinre is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
*
* Copyright (c) 2010, 2011 IBM Corporation
*/

@@ -22,9 +22,9 @@

//-------------------------------------------------------------------
public class Channel {

static public final String AnonymousId = "anonymous";

private String pathPrefix;
private String name;
private String id;
@@ -37,7 +37,7 @@ public class Channel {
private String remoteHost;
private String remoteAddress;
private PrintWriter messageLog;

//---------------------------------------------------------------
public Channel(String pathPrefix, String name, String id, String remoteHost, String remoteAddress) {
this.pathPrefix = pathPrefix;
@@ -58,46 +58,46 @@ public Channel(String pathPrefix, String name, String id, String remoteHost, Str
public Connector getConnector() {
return connector;
}

//---------------------------------------------------------------
public String getRemoteHost() {
return remoteHost;
}

//---------------------------------------------------------------
public String getRemoteAddress() {
return remoteAddress;
}

//---------------------------------------------------------------
protected void _setConnector(Connector connector) {
this.connector = connector;
}

//---------------------------------------------------------------
public void sendCallback(String intfName, String callbackId, Object... args) throws IOException {
if (callbackId == null) return;

List<Object> innerArgs = new ArrayList<Object>();
innerArgs.add(callbackId);
innerArgs.add(Arrays.asList(args));

sendEvent(intfName, "sendCallback", innerArgs.toArray());
}

//---------------------------------------------------------------
public void sendEvent(String intfName, String methodName, Object... args) {
Main.debug(getName() + ": send " + intfName + "." + methodName + "()");

JSONObject response = new JSONObject();

String responseString;
try {
response.put("interface", intfName);
response.put("method", methodName);

List<Object> passedArgs = new ArrayList<Object>(Arrays.asList(args));

response.put("args", passedArgs);

responseString = response.toString();
@@ -106,10 +106,10 @@ public void sendEvent(String intfName, String methodName, Object... args) {
Main.warn("IOException serializing message for " + intfName + "." + methodName);
return;
}

this.postResponse(responseString);
}

//---------------------------------------------------------------
public Object getService(String name) {
try {
@@ -122,12 +122,12 @@ public Object getService(String name) {
throw new RuntimeException(e);
}
}

//---------------------------------------------------------------
@SuppressWarnings("rawtypes")
private Object getService_(String name) throws InstantiationException, IllegalAccessException {
if (serviceMap.containsKey(name)) return serviceMap.get(name);

String klassName = "weinre.server.service." + name;
Class klass = null;
try {
@@ -138,72 +138,72 @@ private Object getService_(String name) throws InstantiationException, IllegalAc
serviceMap.put(name, null);
return null;
}

Object result = klass.newInstance();
serviceMap.put(name, result);
Main.debug("loaded service class: " + klassName);
return result;
}

//---------------------------------------------------------------
public void close() {
isClosed = true;
requestQueue.shutdown();
responseQueue.shutdown();

ChannelManager.$.deregisterChannel(name);
}

//---------------------------------------------------------------
public boolean isClosed() {
return isClosed;
}

//---------------------------------------------------------------
public String getPathPrefix() {
return pathPrefix;
}

//---------------------------------------------------------------
public String getName() {
return name;
}

//---------------------------------------------------------------
public String getId() {
return id;
}

//---------------------------------------------------------------
public long getLastRead() {
return lastRead;
}

//---------------------------------------------------------------
public void updateLastRead() {
lastRead = System.currentTimeMillis();
}

//---------------------------------------------------------------
public void postRequest(String json) {
if (isClosed()) return;

requestQueue.add(json);
log(json);
}

//---------------------------------------------------------------
public void postResponse(String json) {
if (isClosed()) return;

responseQueue.add(json);
log(json);
}

//---------------------------------------------------------------
private void log(String json) {
if (null == messageLog) return;

JSONObject jObject;
try {
jObject = new JSONObject(json);
@@ -212,15 +212,15 @@ private void log(String json) {
catch (JSONException e) {
return;
}

messageLog.print(jObject.toString(true));
messageLog.println(",");
}

//---------------------------------------------------------------
public List<String> getRequests(int timeoutSeconds) throws InterruptedException {
if (isClosed()) return new LinkedList<String>();

List<String> result = requestQueue.getAll(timeoutSeconds, TimeUnit.SECONDS);

return result;
@@ -229,7 +229,7 @@ public List<String> getRequests(int timeoutSeconds) throws InterruptedException
//---------------------------------------------------------------
public List<String> getResponses(int timeoutSeconds) throws InterruptedException {
if (isClosed()) return new LinkedList<String>();

List<String> result = responseQueue.getAll(timeoutSeconds, TimeUnit.SECONDS);

return result;
@@ -60,21 +60,23 @@
<body onload="onLoad()">
<input id="button-start-stuff" type="button" value="start stuff">

<p>exceptions in callbacks<p>
<input id="button-error-DOM-event" type="button" value="DOM addEventHandler">
<input id="button-error-window-event" type="button" value="window addEventHandler">
<input id="button-error-XHR-event" type="button" value="XHR addEventHandler">
<input id="button-error-setTimeout" type="button" value="setTimeout()">
<input id="button-error-setInterval" type="button" value="setInterval()">

<h1>this is a green h1</h1>
<h1 class="blue">this is a blue h1</h1>
<h1 style="color:red">this is a red h1</h1>
<p>Some text, <i>some italic text</i>, and <b>some bold text</b>.

<div id="metrics">a div</div>
<hr>
<p>test exceptions in callbacks:
<div style="margin-left:1em">
<input id="button-error-DOM-event" type="button" value="DOM addEventHandler">
<br><input id="button-error-window-event" type="button" value="window addEventHandler">
<br><input id="button-error-XHR-event" type="button" value="XHR addEventHandler">
<br><input id="button-error-setTimeout" type="button" value="setTimeout()">
<br><input id="button-error-setInterval" type="button" value="setInterval()">
</div>

<input id="button-clear-output" type="button" value="clear output">
<hr>
<p><input id="button-clear-output" type="button" value="clear output">
<div id="output"></div>
</body>

@@ -99,13 +99,13 @@ module.exports = class WiDOMStorageImpl
host: window.location.host
isLocalStorage: false

HookSites.SeesionStorage_setItem.addHooks
HookSites.SessionStorage_setItem.addHooks
after: -> _storageEventHandler storageArea: window.sessionStorage

HookSites.SeesionStorage_removeItem.addHooks
HookSites.SessionStorage_removeItem.addHooks
after: -> _storageEventHandler storageArea: window.sessionStorage

HookSites.SeesionStorage_clear.addHooks
HookSites.SessionStorage_clear.addHooks
after: -> _storageEventHandler storageArea: window.sessionStorage

document.addEventListener "storage", _storageEventHandler, false

0 comments on commit f85a7e2

Please sign in to comment.