Comments (11)
Had the time to test it. It works, I'm merging the PR.
from bonsoir.
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.
@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.
Thanks. Does it occur only on iOS, or do you experience a similar problem on Android ?
from bonsoir.
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.
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();
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.
@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.
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.
Same problem here using iOS.
from bonsoir.
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.
@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)
- ERROR: message sent from native to Flutter on non-platform thread HOT 2
- Crashes related to messages being sent from native to Flutter on non-platform thread HOT 4
- Customise hostname HOT 5
- IP Address Return HOT 3
- Crash when TXT record contains empty properties HOT 2
- java.net.SocketTimeoutException: Poll timed out leads to crash on android few seconds after discovering service HOT 6
- iOS cannot discover a host running on Windows HOT 7
- normalizeType error HOT 4
- Error Redeclaration: BonsoirService HOT 1
- Scan for all the mDNS devices in the network HOT 7
- How can I run this on native android? HOT 8
- Does not work for Flutter-Tizen project HOT 1
- [macOS/windows] Random crash when starting and stopping discovery HOT 8
- Specific characters are missing HOT 2
- Crashes on iOS caused by DNSServiceProcessResult HOT 2
- Broadcast on specific interface HOT 2
- java.util.ConcurrentModificationException is throwed by BonsoirServiceDiscovery.kt HOT 2
- How to get the IP of the resolved service? HOT 4
- what is this error code 4 ? HOT 1
- [Windows] Crash when BonsoirDiscovery start failed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bonsoir.