7

I been trying to search a bit about this and I have faint memories that I have seen presentations of p2p in flash or silverlight and I was wandering if theres any good ways to use this from javascript.

I would like to have the server as a connector of clients not as a proxy of data. Any libs or sites that done something like this you can point to. Google isn't giving me much.

I don't need an easy solution, just somewhere to start from.

Devin Burke
  • 13,642
  • 12
  • 55
  • 82
megakorre
  • 2,213
  • 16
  • 23
  • 1
    You need a proxy server if you plan to use it in the internet. Most computers are behind a NAT. – Fox32 May 30 '11 at 20:50
  • 4
    Javascript also has a same-origin security policy - a script cannot talk to any host it wants it, only its originating server and possibly other servers in the same domain. Even if you did have a P2P client in JS, you'd still need a server-side proxy to make it work. – Marc B May 30 '11 at 20:57
  • But there a several tools for creating p2p connections in JavaScript via a proxy server. – Fox32 May 30 '11 at 21:00
  • sup commentators it dosent need to be with the doms ajax api i dont mind bridging with flash or silverlight or even java if thats required. preferable something cross platformy not some com thing. – megakorre May 30 '11 at 21:00
  • Flash has restrictions on opening connections as well, though you can relax them with a crossdomain.xml definition file on your server. Java would probably need to be done as a signed applet so it can open ad-hoc connections, and/or request elevated privileges each time. – Marc B May 30 '11 at 22:02

7 Answers7

9

Today I found this on Hackernews

http://peerjs.com/

On their page they state:

PeerJS wraps the WebRTC implementation to provide a complete, configurable, and easy-to-use peer-to-peer data API. Each peer simply provides a identifier with which other peers using the same API key can connect.

Sounds really interesting, I have to try this :D

select
  • 2,513
  • 2
  • 25
  • 36
5

WebRTC will be the answer for this soon. It is a W3C standard and is currently being integrated into all browsers.

http://www.webrtc.org/

http://www.webrtc.org/running-the-demos

http://www.w3.org/TR/webrtc/

seeingidog
  • 1,166
  • 9
  • 5
4

The technology you are looking for is called Adobe Cirrus (previously known as Adobe Stratus)

This enables you to achieve p2p communication using the Flash player. It would be a simple matter to then call that from javascript.

Tom
  • 7,994
  • 8
  • 45
  • 62
3

If you want to learn from existing code, I have started a few months ago a project that is using RTMFP (Adobe Cirrus) as communication between the peer connected to the service. If you want to take a look at it, it's available here. I haven't got time to do much documentation so far on it, but if you have question, you can ask them to me on github.

If you want to start with smaller example, I have done a JS interface that enables you to use the P2P connection with Javascript.

HoLyVieR
  • 10,985
  • 5
  • 42
  • 67
2

This might not relate exactly, but websockets might be something interesting to you, if you want it to be iphone/ipad compatible

http://en.wikipedia.org/wiki/WebSockets

http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/

mazlix
  • 6,003
  • 6
  • 33
  • 45
  • Exactly what I thought as well. I would definitely look into node.js since it is a) event based and b) very scalable. – Betamos Jun 09 '11 at 19:55
  • But I think the OP is looking for something that runs in the *browser*. – Tom Jun 09 '11 at 20:29
  • I think phpWebsockets aren't hard to implement but I personally haven't done it yet. – mazlix Jun 09 '11 at 21:24
0

I haven't tried it yet, but anansi might be a good starting point. Requires Node.js

The two links in the "Thanks To" section are definitely worth looking at.

psema4
  • 3,007
  • 1
  • 17
  • 22
0

Or if you need a javascript-only client in the browser are willing to pay for it, check out...

http://www.pubnub.com/

Nick
  • 190
  • 1
  • 2
  • 15