1

This question is more about looking for an idea, rather than an implementation or technical solution. I'd like to hear how you would solve this kind of problem (or task).

I have an application build with Javascript using React & Meteor. At the moment every time a client does something there is a Meteor Call to our server which will write Data to MongoDB and every other client will notice this change (and will respond in some way). This is working fine atm. Now i want to add a new feature which allows two clients to communicate with each other (LAN only - atleast in the first version). So as an example: I have a room with 4 clients - A, B, C and D and i want to match two of them, e.g. A & C. This connection should only exists between those two clients and i want to minimize traffic to my server and meteor calls. (My server should not be involved in this communication at all, besides maybe saving some data every few minutes, but all in all it should work without my server) and it should be possible to open up more than one communication, if A & C are working together B & D should be able to do the same, the data which is transmitted - at this time - is JSON.

Further thoughts: A presses a Button in my webapplication which is a React Component. The React Component than establishes a connection to another person who is also looking for a partner (in the case above C) - Some sort of document/page opens up and both can work on the same document in real time or near real time. In worst case: The communication should be able to work without a connection to my Server (or Internet connection in general), but it doesn't have to.

I first thought about using sockets (SocketIO or something along that line), e.g. A creates a server when he wants to work with C and C connects to A, but this comes with some problems in JS and i am not sure if its really a good way to approach this.

I'd like to hear some other ideas, perhaps im running in a completely wrong direction.

Dart
  • 13
  • 3
  • 2
    Sounds like you want webrtc. You can do browser to browser communication and should be possible through lan. https://webrtc.org/ – Derrick Gremillion Mar 30 '20 at 14:38
  • Hi Dart, Welcome to StackOverflow! SO is specifically a question-answer site, not a discussion forum. As it stands, your question is far too broad, and subject to personal opinion, both of which are considered 'off-topic' for SO. For further information, please review what is considered to be 'on-topic' for SO. For further information, please see [how to ask good questions](http://stackoverflow.com/help/how-to-ask), and take the [tour of the site](http://stackoverflow.com/tour). – Fred Stark Mar 30 '20 at 22:36
  • A good place to ask questions like this for Meteor is the forums: forums.meteor.com – Fred Stark Mar 30 '20 at 22:36

1 Answers1

0

Use the WebRTC API.

Although often associated with real time audio/video communication, it can also be used for peer-to-peer communication with arbitrary data.

As far as I know this is, as of this writing, the only client-side web-native peer-to-peer API available which is widely implemented by major browser vendors.

tne
  • 6,417
  • 2
  • 38
  • 62