Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Fix Issue 129 #130

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions src/android/OpenTokAndroidPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,28 @@ public void subscribeToVideo(boolean value) {
}
}

private class PubRunnable implements Runnable {
CallbackContext mCallbackContext;
public PubRunnable(CallbackContext callbackContext) {
mCallbackContext = callbackContext;
}
public void run() {
myPublisher.getImgData(mCallbackContext);
}
}

private class SubRunnable implements Runnable {
RunnableSubscriber mRunsub;
CallbackContext mCallbackContext;
public SubRunnable(RunnableSubscriber runsub, CallbackContext callbackContext) {
mRunsub = runsub;
mCallbackContext = callbackContext;
}
public void run() {
mRunsub.getImgData(mCallbackContext);
}
}

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
_cordova = cordova;
Expand Down Expand Up @@ -668,20 +690,12 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
}
} else if (action.equals("getImgData")) {
if (args.getString(0).equals("TBPublisher") && myPublisher != null && sessionConnected) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
myPublisher.getImgData(callbackContext);
}
});
cordova.getThreadPool().execute(new PubRunnable(callbackContext));
return true;
} else {
RunnableSubscriber runsub = subscriberCollection.get(args.getString(0));
if (runsub != null) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
runsub.getImgData(callbackContext);
}
});
cordova.getThreadPool().execute(new SubRunnable(runsub, callbackContext));
runsub.getImgData(callbackContext);
return true;
}
Expand Down Expand Up @@ -1089,4 +1103,4 @@ public void onStreamVideoTypeChanged(Session arg0, Stream arg1,
// TODO Auto-generated method stub

}
}
}