monicanagent / cypherpoker.js

An open source peer-to-peer poker platform with cryptocurrency integration written in JavaScript.
MIT License
104 stars 42 forks source link

Implement WebRTC support #22

Closed monicanagent closed 5 years ago

monicanagent commented 5 years ago

Add reliable NAT hole punching/binding capabilities to server code (https://github.com/monicanagent/cypherpoker.js/tree/master/src/server), in order to enable public server/peer node capabilities without the need for manual router updates.

monicanagent commented 5 years ago

This might be a good place to start: https://github.com/freedomjs/freedom-port-control

monicanagent commented 5 years ago

Unfortunately none of the existing NPM libraries and NAT hole punching techniques (NAT-PMP, PCP, uPnP) seem to be effective. However, since Electron includes a fully functional version of Chrome, WebRTC can be leveraged to accomplish this functionality.

In addition to updating the P2P communication functionality of CypherPoker.JS, RPC functions should also be call-able via WebRTC. This will require some sort of dynamic server and message routing capabilities with the following logic:

Initial connect:

On table join:

On send-to-peer:

On invoke RPC:

The server will also need to be updated in order to route messages between WebRTC-connected peers and WSS-connected peers.

Most likely there will be additional implementation details to follow.

monicanagent commented 5 years ago

Updated issue title to reflect new direction (re: WebRTC)

monicanagent commented 5 years ago

Implemented in revision 167 (https://github.com/monicanagent/cypherpoker.js/commit/1af643d72bb416c49fdd7dd98f44cd435f2a9ce5).