When I started looking, I did find some older github projects that tested using the streams capability – and how many simultaneous streams could be triggered and used effectively – but no published results. There’s a third transport mechanism, which uses open ended streams, that I haven’t yet touched. The session delegate has callbacks for when it starts transfering and when it completes. I haven’t experimented with this layer, but I’m guessing it’s a bit more optimized for reading a large file and streaming it out. Session also has the concept of not just sending Data, but of explicitly transferring (presumably larger) resources that are URL based. Session is a bi-directional communications channel, and once you are connected, either side can send data for the other to receive. I haven’t measured exactly how fast, or how consistently, these updates propagate. For example, when your iOS device goes to sleep, or you set the device into airplane mode. In my experience so far, you don’t spend very long in the connecting state, and state updates propagate pretty quickly (within a second or two) when the infrastructure changes. The session state is a tri-state thing: notConnected, connecting, or connected. Session is designed to do this through delegate method callbacks to session(_:peer:didChange:) which is how you get state changes on for connections changes, and information on to whom you are connected. While the browser allows you to invite, and the advertiser to accept, it is the session that gives you detail on what’s happening. Before you get into sending data, however, you need to be connected. Session has an active side and a reactive side to it’s API – methods like send(_:toPeers:with:) pair to a session delegate responding using the method session(_:didReceive:fromPeer:). The session ( MCSession) is the heart of the communications from here. You use the browser to “invite” a found peer to a session, and the corresponding advertiser has a delegate you use to accept invites. Both can advertise, and it’s makes for interesting viewing of “who’s out there” – but the heart that enables data transfer is another layer down: MCSession. When I first started in, having glanced through the developer docs, I thought you needed to have both sides actively advertising for this to work. It doesn’t need to be set up bi-directionally, although it can. One side can advertise, the other browse, and you can establish a connection on that basis. ![]() It wasn’t completely obvious to me at first, but you don’t need both sides of the peer to peer conversation doing advertising in order to make a connection. The structure starts with an advertiser, which is paired with an advertising browser. Unfortunately, the documentation doesn’t make how to use them and what to expect entirely clear. You do get a nicely designed cascade of objects, all of which leverage the delegate/protocol structure to do their thing. One of the “quirks” of this technology is that you don’t direct what transport is used, nor do you get information about the transport. Some of it uses Bonjour (aka zeroconf), and I suspect other mechanisms as well. ![]() There’s a lot of “magic” in that capability, layering over underlying technologies and dealing with the advertise and connect mechanisms. ![]() The promise of what this framework does is compelling, which is to seamlessly enable peer to peer networking, layering over any local transport available (bluetooth, ethernet if available, a local wifi connection, or a common wifi infrastructure). It’s a neat framework, and there are community-based libraries that layer over it to make it easier to use for some use cases: MultipeerKit ( src) being the one that stood out to me. Probably not (so far) and it's probably on the right tail of the geek distribution, though I'm tempted to try it.A few weeks ago, I got curious about the MultipeerConnectivity framework available across Apple’s platforms. ![]() I don't know whether there are online collaboration systems that support Bookdown. GitHub markdown strikes me as less interesting than some of the alternatives, such as Bookdown. Eventually I lost my energy and motivation fighting with it. Frequently misquoted dialogue from The Treasure of the Sierra Madre springs to mind. As for rewards, I logged back in to find that I have earned 17 badges. It will save files to Google Drive (the same file more than once, it seemed) but for collaboration I found working with Google Docs easier (read: my collaborators wouldn't use StackEdit). Edits of blog posts had to be updated on blogger with the blogpost ID extracted from the post URL on blogger and filled into a dialog box in StackEdit. I've used it for publishing GitHub style markdown files with KaTeX (if I recall) to, but the workflow is awkward.
0 Comments
Leave a Reply. |