wifidirectplugin 1.2.9 → 1.3.0

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.
@@ -27,6 +27,8 @@ public class WifiDirectPlugin extends Plugin {
27
27
  private List<WifiP2pDevice> peerWifiDirDevices = new ArrayList<>();
28
28
  private static final String TAG = "WifiDirectPlugin";
29
29
 
30
+ private PluginCall pendingConnectCall = null;
31
+
30
32
  private final BroadcastReceiver wifiP2pReceiver = new BroadcastReceiver() {
31
33
  @Override
32
34
  public void onReceive(Context context, Intent intent) {
@@ -36,11 +38,21 @@ public class WifiDirectPlugin extends Plugin {
36
38
  NetworkInfo networkInfo = intent.getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);
37
39
  if (networkInfo != null && networkInfo.isConnected()) {
38
40
  Log.d(TAG, "Wi-Fi Direct connected");
39
- // 필요한 경우 연결된 상태를 Flutter/Ionic에 전달하는 코드를 여기서 실행
40
- // 예: call JavaScript 이벤트 전송 또는 콜백 호출
41
+ if (pendingConnectCall != null) {
42
+ manager.requestConnectionInfo(channel, info -> {
43
+ if (info != null && info.groupFormed) {
44
+ Log.d(TAG, "Group formed, resolving connectToDevice");
45
+ pendingConnectCall.resolve();
46
+ pendingConnectCall = null;
47
+ }
48
+ });
49
+ }
41
50
  } else {
42
51
  Log.d(TAG, "Wi-Fi Direct disconnected");
43
- // 연결 해제 상태 처리
52
+ if (pendingConnectCall != null) {
53
+ pendingConnectCall.reject("Wi-Fi Direct connection lost before group formed");
54
+ pendingConnectCall = null;
55
+ }
44
56
  }
45
57
  }
46
58
  }
@@ -182,18 +194,22 @@ public class WifiDirectPlugin extends Plugin {
182
194
  manager.connect(channel, config, new WifiP2pManager.ActionListener() {
183
195
  @Override
184
196
  public void onSuccess() {
185
- Log.d(TAG, "connect onSuccess Called");
186
- call.resolve();
197
+ // connect request accepted — group formation is async
198
+ // resolve will be called from BroadcastReceiver once group is formed
199
+ Log.d(TAG, "connect onSuccess Called, waiting for group formation");
200
+ pendingConnectCall = call;
187
201
  }
188
202
 
189
203
  @Override
190
204
  public void onFailure(int reason) {
191
205
  Log.e(TAG, "connect onFailure Called");
206
+ pendingConnectCall = null;
192
207
  call.reject("Connection failed: " + reason);
193
208
  }
194
209
  });
195
210
  } catch (Exception e) {
196
211
  Log.e(TAG, "connect exception", e);
212
+ pendingConnectCall = null;
197
213
  call.reject("Connection exception: " + e.getMessage());
198
214
  }
199
215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wifidirectplugin",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "description": "HT-Installer Wifi Direct Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",