How can I implement simple serverless p2p browser to browser messaging with minimal overhead?

后端 未结 2 731
傲寒
傲寒 2021-01-31 10:16

I\'m trying to create some basic implementations of simple games (tic tac toe is the starting project) which can be played over the internet without requiring a central server.

相关标签:
2条回答
  • 2021-01-31 10:39

    In summary, if ajax can send a request to a specified IP and listen for a response.. why can't i get simple peer to peer messaging in pure js? Or can I?

    It's due to the fact that an ajax request must be handled by an HTTP server so you still need to install a server to every clients.

    say you want

    1. free
    2. no external servers
    3. no client downloads

    I would say it is impossible to archive with all of these requirements except that you cut one of them off.

    My suggestion is pubnub. This solution still need a server and it is not free(they have a free usage tier). But the good thing is you have an imitate p2p connection without doing server things and no client download needed.

    0 讨论(0)
  • 2021-01-31 10:44

    After pubnub was recommended, I looked there and was partially impressed. However, I eventually stumbled across exactly what I was looking for UNBELIEVABLY. RTCDataChannel is the answer. This site finally showed that what I want is possible. The browser support for this functionality is small but growing and the entire ordeal has strengthened my faith in the growing support for peer to peer applications in the browser community.

    0 讨论(0)
提交回复
热议问题