Giter VIP home page Giter VIP logo

Comments (11)

Skyost avatar Skyost commented on August 26, 2024 1

Had the time to test it. It works, I'm merging the PR.

from bonsoir.

Skyost avatar Skyost commented on August 26, 2024

Hey,

Would it be possible to see your code please ? Also, please note that the example app has been updated to 3.0.0, feel free to check it out to adapt your code to this new version.

from bonsoir.

fptavares avatar fptavares commented on August 26, 2024

@Skyost, I also see this happening. The first time I start discovery, the services are found, and they are also resolved after I request for them to be resolved. Then I stop discovery.

After that first discovery, resolve never works anymore. Immediately after BonsoirDiscoveryEventType.discoveryServiceFound, a BonsoirDiscoveryEventType.discoveryStopped comes right after. Resolution of the services never happens anymore, no success and no failure.

Here's the code:

Future<void> scan(String mdnsName) async {
    final discovery = BonsoirDiscovery(type: mdnsName);
    await discovery.ready;

    discovery.eventStream?.listen((event) {
      print('Bonsoir event received: ${event.type}');
      if (event.type == BonsoirDiscoveryEventType.discoveryServiceFound) {
        print('Service found: ${event.service?.toJson()}');
        event.service!.resolve(discovery.serviceResolver);
      } else if (event.type == BonsoirDiscoveryEventType.discoveryServiceResolved) {
        print('Service resolved: ${event.service?.toJson()}');
      }
    });

    await discovery.start();
    // wait 5 seconds
    await Future.delayed(const Duration(seconds: 5));

    await discovery.stop();
}

This same code runs fine and services are resolved the first time it runs. Any time I call this function again, discovery is stopped automatically after the services are found, and resolve never works again.

Using Bonsoir 3.0.0+1

from bonsoir.

Skyost avatar Skyost commented on August 26, 2024

Thanks. Does it occur only on iOS, or do you experience a similar problem on Android ?

from bonsoir.

fptavares avatar fptavares commented on August 26, 2024

I don't have an Android device to test on, but I see the same behavior on both iOS and macOS. After downgrading to version 2.2.0+1 and commenting out the line with the resolve request, it works fine every time the function is called.

from bonsoir.

ed-oo avatar ed-oo commented on August 26, 2024

I found another problem in 2.2.0+1 on android in resolver_service.dart
My code:

BonsoirService service = BonsoirService(
          name: "Serveur John",
          type: "_john-server._tcp",
          port: 8299,
        );
this._bonsoirBroadcast = BonsoirBroadcast(service: service);
await this._bonsoirBroadcast!.ready;
await this._bonsoirBroadcast!.start();

On Debug:
image

static String _filterType(String type) {
    if (type.startsWith('._')) {
      type = type.substring(1);
    }
    if (type.endsWith('_tcp.') || type.endsWith('_udp.')) {
      type = type.substring(0, type.length - 1);
    }
    return type;
  }

_filterType have String not nullable parameter and service.type == null (even if i specified a type, i don't understand)

from bonsoir.

Skyost avatar Skyost commented on August 26, 2024

@fptavares I'll finally have the time to test your code tomorrow. Will tell you if I'm able to reproduce.
@ed-oo I don't understand your last message, and as I don't have access to your prior code, I may not be able to reproduce your issue.

from bonsoir.

julianscheel avatar julianscheel commented on August 26, 2024

I can confirm this issue exists on macOS as well.
Can also easily reproduced by just doing a hot restart. After the first hot restart the discovery stops immediately after services are found.

from bonsoir.

rope50 avatar rope50 commented on August 26, 2024

Same problem here using iOS.

from bonsoir.

Skyost avatar Skyost commented on August 26, 2024

Okay so it seems to be a problem with the Darwin implementation. Anyway, we have to rewrite it in order to get rid of NetService.

from bonsoir.

Skyost avatar Skyost commented on August 26, 2024

@ed-oo, @julianscheel, @rope50, @fptavares :

I've rewritten the Darwin project to remove the dependence on NetService. I've already tested it on macOS (not 100%, attributes are still untested, but the major features seem to work).

Can you please it on your side ? To do so, in your pubspec.yaml :

dependency_overrides:
  bonsoir:
    git:
      url: https://github.com/Skyost/Bonsoir.git
      ref: darwin-network
      path: bonsoir
  bonsoir_android:
    git:
      url: https://github.com/Skyost/Bonsoir.git
      ref: darwin-network
      path: bonsoir_android
  bonsoir_darwin:
    git:
      url: https://github.com/Skyost/Bonsoir.git
      ref: darwin-network
      path: bonsoir_darwin
  bonsoir_platform_interface:
    git:
      url: https://github.com/Skyost/Bonsoir.git
      ref: darwin-network
      path: bonsoir_platform_interface

then flutter pub get. May also need pod update.

from bonsoir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.