1

Is it technically possible to create a WebRTC connection for transferring JSON between two WebRTC endpoints spawned in the same script on the same page in the same browser?

For example, could I code an HTML5 offline app to communicate between different parts of the app over "local" WebRTC?

This is not a question about whether this is a good idea or whether I should be doing something a different way! Just "is this technically possible?"

Cœur
  • 37,241
  • 25
  • 195
  • 267
themirror
  • 9,963
  • 7
  • 46
  • 79
  • @jibrewery showed the "simplest webrtc example on two tab pages on the same browser without internet" in another stackoverflow question. But the stackoverflow moderator prevent me to paste a link to the anwer in that question. – diyism Feb 21 '19 at 10:21
  • the anwser link: http://stackoverflow.com/a/35300241/264181 – diyism Feb 21 '19 at 10:22

2 Answers2

0

No, this is not possible, because the implementation of web sockets in a browser are client implementations. For point-to-point communication you would need a web socket server instance, which you cannot create in a browser. Maybe, you should have a look at WebRTC.

Kurt Pattyn
  • 2,758
  • 2
  • 30
  • 42
0

You can find a very good sample in this web: https://bitbucket.org/webrtc/codelab

To be more exact, in the step 5:

"In the examples already completed, the 'sender' and 'receiver' RTCPeerConnection objects are on the same page, so signaling is simply a matter of passing objects between methods.

In a real world application, the sender and receiver RTCPeerConnections are not on the same page, and we need a way for them to communicate metadata."

You can run the samples to understand better how it works.

raposo
  • 76
  • 2