diff --git a/android/src/main/kotlin/de/mintware/flutter_p2p/wifi_direct/SocketPool.kt b/android/src/main/kotlin/de/mintware/flutter_p2p/wifi_direct/SocketPool.kt index 7ac4c60..c65987a 100644 --- a/android/src/main/kotlin/de/mintware/flutter_p2p/wifi_direct/SocketPool.kt +++ b/android/src/main/kotlin/de/mintware/flutter_p2p/wifi_direct/SocketPool.kt @@ -21,7 +21,8 @@ class SocketPool(private val inputStreamHandler: StreamHandler) { private val hosts = mutableListOf() fun openSocket(port: Int): Host { - if (getHostByPort(port) != null) { + val h = getHostByPort(port); + if (h != null && !h.serverSocket.isClosed) { throw Exception("A socket with this port already exist") } @@ -43,6 +44,7 @@ class SocketPool(private val inputStreamHandler: StreamHandler) { val socket: Host = getHostByPort(port) ?: throw Exception("A socket with this port is not registered.") socket.serverSocket.close() + hosts.remove(socket); } fun connectToHost(address: String, port: Int, timeout: Int): Client { diff --git a/example/pubspec.lock b/example/pubspec.lock deleted file mode 100644 index eeee9b4..0000000 --- a/example/pubspec.lock +++ /dev/null @@ -1,209 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.1" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.3" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.14.12" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" - fixnum: - dependency: transitive - description: - name: fixnum - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.9" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_p2p: - dependency: "direct dev" - description: - path: ".." - relative: true - source: path - version: "1.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.6" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.8" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.4" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - protobuf: - dependency: transitive - description: - name: protobuf - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.7.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.3" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.15" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.6" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" -sdks: - dart: ">=2.6.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index cd098bc..e0119ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,15 +14,9 @@ dependencies: flutter: sdk: flutter -dev_dependencies: - flutter_test: - sdk: flutter - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - flutter: plugin: - android: - package: de.mintware.flutter_p2p - pluginClass: FlutterP2pPlugin \ No newline at end of file + platforms: + android: + package: de.mintware.flutter_p2p + pluginClass: FlutterP2pPlugin