New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS: remove Ti.Network.TCPSocket #11362
Conversation
|
OK, after digging deeper - my changes definitely didn't cause the issue. Looks to be a main thread related issue: https://jira.appcelerator.org/browse/TIMOB-27076 Basically the bonjour APIs had locks on the main thread to wait for the service resolution (or publish/etc) to occur before returning (making the API sync). As soon as I commented out the lock wait, it worked. The issue is that the API then becomes async and we'd need to fire an event to notify of success/failure to resolve/publish/etc. I don't know if we can explicitly run the resolution/publish off the main thread to "fix" this. |
+1 on the Node style callbacks for the new async versions of mentioned functions. Since we are investing so much effort to increase node compatibility, our own API should also go this way (or promise as you already mentioned). @sgtcoolguy judging by the PR description, i guess you last comment is obsolete now, and you already addressed that issue? |
b71ec07
to
4d2d96d
Compare
4d2d96d
to
dfa3b78
Compare
For now I'm keeping both events and optional callbacks, so you can pick or choose which way to deal with things. I'd prefer callbacks myself, but most of our APIs are event based so it feels odd not to provide that for now. |
af4ce6c
to
285279c
Compare
* remove deprecated constants used by legacy tcp socket proxy * make bonjour service methods async, add events for results * move bonjour service proxy to obj-c api * support optional arguments on bonjour service methods * optional last callback arg for each method * optional timeout for resolve as first arg BREAKING CHANGE: Ti.Network.TCPSocket has been removed, use Ti.Network.Socket.TCP in it's place. BREAKING CHANGE: Ti.Network.BonjourService methods have become asynchronous. Use optional callback arguments or event listeners to react to results. Fixes TIMOB-27619, TIMOB-27076
* mark legacy TCP socket type and related network constants removed * update BonjourService to add events * note that BonjourService resolution/publish is async in summary * update defaults for Bonjour proxy properties * document optional callbacks on BonjourService methods * add examples of usage for BonjourService
6be27ba
to
77223bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few changes required as mentioned in comments.
@vijaysingh-axway Pushed another commit to address your feedback (and another issue I saw internally with setSocket) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR passed.
FR Passed. Checked above code with different Looks good. Studio Ver: 6.0.0.201911251516 |
JIRA:
Optional Description:
We have kept around
Ti.Network.TCPSocket
since SDK 1.7 because it's used by the bonjour service code on iOS. (The new class isTi.Network.Socket.TCP
)This PR attempts to finally remove it.
In addition, when moving to running on the main thread, our APIs were broken in that they'd block forever (
Ti.Network.BonjourService.publish()
andTi.Network.BonjourService.resolve()
). This PR removes the fiddling with run loops and usage of locks, rendering thestop()
,publish()
andresolve()
methods async. In order to be notified of the results/completion of those methods, newpublish
,stop
andresolve
events were added. I also accept optional callback arguments to these functions. These operate like typical Node-style callback functions, with the first argument an optionalError
(for error conditions), and the second argument being a boolean (for success conditions).I've opted to retain both styles of usage since most of our APIs are event based, but longer-term we'd like to conform to Node.JS API styles more consistently.
Test code:
I have now tried with code I found at https://github.com/rborn/Advanced-Titanium-Tutorial---Bonjour-Networking/blob/master/Resources/bj.js as well, which creates a service and publishes it. I included an example in my commits for the docs for both browsing and resolving; and creating and publishing a service. Both worked for me locally.