Permalink
Browse files

updated interaction between websocket thread and UI thread by emplyin…

…g additional thread in between
  • Loading branch information...
anismiles
anismiles committed Aug 25, 2011
1 parent 9780a84 commit 087f7a93d46f92cb037d2b451a4d253a65f5f015
Showing with 10 additions and 11 deletions.
  1. +10 −11 src/com/strumsoft/websocket/phonegap/WebSocket.java
@@ -340,40 +340,39 @@ public void run() {
* Message from websocket server
*/
public void onMessage(final String msg) {
new Thread(new Runnable() {
appView.post(new Runnable() {
@Override
public void run() {
appView.loadUrl(buildJavaScriptData(EVENT_ON_MESSAGE, msg));
}
}).start();
});
}
public void onOpen() {
new Thread(new Runnable() {
appView.post(new Runnable() {
@Override
public void run() {
appView.loadUrl(buildJavaScriptData(EVENT_ON_OPEN, BLANK_MESSAGE));
}
}).start();
});
}
public void onClose() {
new Thread(new Runnable() {
appView.post(new Runnable() {
@Override
public void run() {
appView.loadUrl(buildJavaScriptData(EVENT_ON_CLOSE, BLANK_MESSAGE));
}
}).start();
});
}
public void onError(Throwable t) {
final String msg = t.getMessage();
new Thread(new Runnable() {
public void onError(final Throwable t) {
appView.post(new Runnable() {
@Override
public void run() {
appView.loadUrl(buildJavaScriptData(EVENT_ON_ERROR, msg));
appView.loadUrl(buildJavaScriptData(EVENT_ON_ERROR, t.getMessage()));
}
}).start();
});
}
public String getId() {

0 comments on commit 087f7a9

Please sign in to comment.