Peer to peer message relay using Multipeer Connectivity - ios

I am creating an application that uses the Multipeer Connectivity framework provided by iOS 7.
I was able to successfully transmit messages from devices connected over only bluetooth in a network with messages but what I need to do is to relay a message over .
Say for example Device A,Device B and Device C are connected with each other over Bluetooth while Device A moves away to a distance where it can only see Device B in range but not Device C and wants to send a message over?
I have written the code for message relay which successfully sends message from Device A to Device C via device B but right now it is only happening when all 3 devices are connected in the network,when device A moves away it completely loses B and C from range. I am unable to create a network where A is connected to B while B is connected to C and A and B are not connected. So Unable to test the code properly.Any inputs would be appreciated.

Related

Building a simple control panel for an array of Chromecast devices

Background: My company is moving into new offices and we would like to control all of the LCD TVs on our walls (around 50 screens) using Chromecast Ultra devices, such that each will display a different webpage. So that's 50 Chromecasts that will be connected via Ethernet to our local network.
I reviewed the Cast SDK documentation on how to build a custom receiver application, but to my understanding this is for sending a message to a single device every time. I wish to build a simple control panel (can be either a web app or an Android app), where I can select a number of Chromecast devices and send all of them a message (with a URL to load).
Can a message be sent to multiple Chromecast devices at once, without having to send the message to each device manually?
No; using the Cast SDK, you have to send a message to each device manually by establishing a connection to that device and sending your message. Alternatively, your receiver running on your chromecast devices can communicate with your backend server and you can use a PUSH mechanism to send messages to your receivers from your server; that, however, is outside of the Cast SDK.

Multipeer Connectivity Framework

My question is very simple, and is related to the Multipeer Connectivity Framework in iOS.
O know that I can have multiple sessions running on my device. However, suppose a case in which I have three devices (A, B, and C). Can I connect device A to B and then connect B to C ? I think my quesiton is: Can I have have multiple sessions even as a peer ? For instance, in my previous example, device B is connected to device A and at the same time is connected to device C. This means that device B is a peer connected to a session with device A and also has its own session and establishes a connection with device C.
Thanks.

How to send data to an iphone which is turned into a iBeacon?

how is it possible to send data to an iPhone which acts as an iBeacon?
I am looking for an process as the following:
Search nearby iBeacons
Connect to some iBeacon
Exchange data between the devices
Does anybody know how to put the different bluetooth functions together to make
this possible?
thx in advance
Standard iBeacons are transmit-only devices that can be seen by mobile devices, but don't actually "connect" to them or exchange data.
But you can still do what you are asking if you have an app on all devices as well as a web service to do the data transfer. This would allow devices A and B to detect each other when they are nearby and exchange data. Here's how:
Your app on devices A and B alternates between acting as an iBeacon (advertising its presence with an application-specific identifier and a phone-specific identifier) and ranging for iBeacon signals including the application-specific identifier.
During its ranging cycle, your app on device A will detect an iBeacon transmission from device B, which includes both your application identifier and the device identifier of B.
App A then makes a "write" call to the web service with a source of "A" and a destination of "B", along with any data you want to transfer, like "Device A says hello to device B."
The app would also periodically make a "read" call to the web service. In this example, device B would read any information destined for B, and the web service would return a record that device A had send it a message with the data "Device A says hello to device B."
Because the same process is also running on both phones, this communication can happen both ways.
iBeacon is a proximity technology and isn't designed for data interchange. However, since the Bluetooth stack is going to be active on your iPhone acting as the beacon (so it can advertise its proximity UUID), you can use Core Bluetooth to connect to the beacon and exchange data between the devices.
Does it specifically need to use iBeacon technology? The reason I ask is that from reading your description of the process, you could achieve the same thing using iOS 7's Multipeer Connectivity. It's able to abstract out all the technical complexities of connecting 2 iOS devices together regardless of the interface, be it WiFi or Bluetooth. I've managed to build something similar using MCNearbyServiceBrowser, MCNearbyServiceAdvertiser, and MCSession classes.

Is it possible to build socket connection between 2 iOS devices

Is it possible to build a socket connection between 2 iOS devices connected to the same network (Without net)?
if it's possible .. Is (CocoaAsyncSocket project) useful for me?
I just want to send a message from Device A to Device B which put the app in background .. when Device B receive the message should show notification to return the app to foreground.
It's not for the App Store, so I don't care if Apple would reject the app because of this behavior.
Yes, you can do it, and yes, CocoaAsyncSocket would be useful. If you don't have to worry about the carrier network's firewalls and filters, then you should certainly be able to build a client-server app running on two iOS devices. One opens the server socket to listen, and the other one (the client) connects, via the Wi-Fi network.
Trying searching on Google (e.g. "CocoaAsyncSocket iPhone iOS site:stackoverflow.com") or directly here on Stack Overflow.
Here's somebody who seems to have accomplished this
Another link
And a post from Robbie Hanson himself, referring you to the EchoServer projects in the github repository
EchoServer project
You may have to use a static IP address for the server device (I'm not sure how much control you have over the Wi-Fi network's configuration), or use some other mechanism for letting the two devices discover each other.

Use Wifi Instead of Bluetooth in game development kit

I am using GameKit to connect 2 device (peer to peer) way.
I don't want to use bluetooth to connect the devices - I want to use the local wifi router.(the router does not have internet access).
I am able to do every thing using bluetooth but not wifi - I even modified this line:
picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
to
picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby | GKPeerPickerConnectionTypeOnline;
but this simple change added a tab saying online, when I tap it it does nothing and when I tap the other tab that says nearby it connects using bluetooth. What's the problem?

Resources