wifidirectplugin 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,7 @@ public class WifiDirectPlugin extends Plugin {
31
31
  private IntentFilter intentFilter;
32
32
 
33
33
  private final Handler handler = new Handler(Looper.getMainLooper());
34
+ private boolean isConnecting = false;
34
35
 
35
36
  @Override
36
37
  public void load() {
@@ -57,16 +58,28 @@ public class WifiDirectPlugin extends Plugin {
57
58
  }
58
59
 
59
60
  private void cancelExistingConnection(Runnable onComplete) {
60
- manager.cancelConnect(channel, new WifiP2pManager.ActionListener() {
61
- @Override
62
- public void onSuccess() {
63
- onComplete.run();
64
- }
65
- @Override
66
- public void onFailure(int reason) {
67
- onComplete.run();
68
- }
69
- });
61
+ if (!isConnecting) {
62
+ onComplete.run();
63
+ return;
64
+ }
65
+
66
+ try {
67
+
68
+ manager.cancelConnect(channel, new WifiP2pManager.ActionListener() {
69
+ @Override
70
+ public void onSuccess() {
71
+ onComplete.run();
72
+ }
73
+
74
+ @Override
75
+ public void onFailure(int reason) {
76
+ onComplete.run();
77
+ }
78
+ });
79
+ } catch (Throwable t) {
80
+ isConnecting = false;
81
+ onComplete.run();
82
+ }
70
83
  }
71
84
 
72
85
  @PluginMethod
@@ -136,6 +149,8 @@ public class WifiDirectPlugin extends Plugin {
136
149
  }
137
150
 
138
151
  private void connectToDevice(WifiP2pDevice device, PluginCall call) {
152
+ isConnecting = true;
153
+
139
154
  WifiP2pConfig config = new WifiP2pConfig();
140
155
  config.deviceAddress = device.deviceAddress;
141
156
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wifidirectplugin",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "HT-Installer Wifi Direct Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",