cocoanetics / dtbonjour Goto Github PK
View Code? Open in Web Editor NEWFramework for Communicating over Bonjour+Wifi
License: BSD 2-Clause "Simplified" License
Framework for Communicating over Bonjour+Wifi
License: BSD 2-Clause "Simplified" License
Currently, -[DTBonjourDataConnection isOpen]
checks to see if the input and output streams are both anything but open (if their streamStatus != open, then the method returns NO). This is not the correct behavior.
A more enlightened approach would be to check if the streams are closed:
- (BOOL)isOpen {
if (!_inputStream) return NO;
if (!_outputStream) return NO;
if (NSStreamStatusClosed == _inputStream.streamStatus) return NO;
if (NSStreamStatusClosed == _outputStream.streamStatus) return NO;
return YES;
}
Furthermore, Apple documentation says that specific stream statuses denote that the connection is indeed open and useable, but some form of metadata is being loaded about said connection. The current approach ignores this detail.
When building DTBonjour with Xcode 5.1 there is an "Unknown type name 'CGFloat'"
This is because CGFloat
is defined in CoreGraphics. We want the timeout to be a double. So this should be NSTimeInterval
instead.
I'm not sure if this is an issue or I am misunderstanding the way something works.
The following method - (BOOL)sendObject:(id)object error:(NSError **)error
in DTBonjourConnection makes a call to [self _startOutput];
on the Main Thread.
Am I right in thinking that when the data is being written to the output stream that this is happening on the Main Thread? Should this not be happening on a background for performance and parallelization of commands?
I had the following code in my app:
_dataConnection = [[DTBonjourDataConnection alloc] initWithService:aNetService];
// later
if ( !_dataConnection.isOpen ) {
if ( ![_dataConnection open] ) {
NSLog(@"Error: couldn't open connection to net service");
}
}
After over an hour of trying to figure out why the server wasn't accepting connections, it occurred to me that isOpen
might be returning true when I was expecting it to be false. This was indeed the case. In looking at the isOpen
code:
- (BOOL)isOpen
{
return (_inputStream&&_outputStream);
}
_inputStream
and _outputStream
are initialized in the initWithService
constructor, though they are not opened until open
is called. This renders isOpen essentially useless. Would not something like this be better?:
- (BOOL)isOpen
{
return ([_inputStream streamStatus] == NSStreamStatusOpen &&
[_outputStream streamStatus] == NSStreamStatusOpen);
}
I can submit a pull request if you'd like, I may be overlooking something though so I thought I'd check first.
Has to be changed in the following file: DTBonjourDataConnection.m
I have a Mac OS X Mountain Lion. When selecting OS X as target, no libDTBonjour library file is produced.
Only when selecting iOS as a target a library file is produced.
Execute the 5.1 Upgrade Checks to make warnings disappear.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.