1

I want to build an app that allow P2P communication(send message, exchange files), I build the app with phonegap, since I want my app cross platform.

I know WebRTC allow real-time communication, but browsers doesn't support it very well. I also found Websocket plugin for phonegap, this satisfied part of my requirement, I can use this send message, but if I use websocket to send files from A to B, I guess all traffic will go through my server, it a pressure for server and I don't want my server carry so much traffic. I can't make a peer to peer connection between A and B.

Is there anyway to make a P2P communication on phone? Any workaround solution is also welcome.

yuyue007
  • 1,219
  • 3
  • 14
  • 25

3 Answers3

0

You can do peer to peer connections using Flash or the recent WebRTC. Currently these are the only options you can use to do so, as WebSockets will only connect to a server.

As Flash is not supported by most phones (only Android < 4.0 has support), you can only use WebRTC. But WebRTC is only available on Chrome Beta for now, so you'll still have a cross platform app that will not work in most platforms/devices.

You will have to go through server (WebSockets or HTTP) to increase the number of devices you can cover.

nakib
  • 4,304
  • 2
  • 28
  • 39
0

You can use Boost asio sockets to build you own P2P app. but you need to build it for Android NDK and IOS. Please do take a look at these links before you get into a conclusion Official "Boost library" Support for Android and iOS? Limitations to using (Boost) Asio with Android NDK http://beta.boost.org/development/tests/trunk/developer/summary.html
http://www.codeproject.com/Tips/555070/Boost-vs-OSX-iOS-XCode

Hope it helps

Community
  • 1
  • 1
Navin
  • 554
  • 2
  • 9
  • 31
0

On WebRTC you can use RTCDataChannel, in my experience, on chrome, using this involves writing a lot of code around reliability as the packets arrive out of order or not at all if sent too quickly. However I think as the WebRTC spec evolves this will improve with implementation.

Use this for generating a RTCDataChannel enabled peerconnection:

var localpeer = new webkitRTCPeerConnection(localConfig,{ 'optional': [{'RtpDataChannels': true }] });
harsh
  • 128
  • 1
  • 1
  • 5