anysocket
anysocket copied to clipboard
How would one create Anysocket using ptp2
https://github.com/subins2000/p2pt allows to connect peers in browsers using existing webtorrent tracker network, which if performant, means one could setup a webrtc "server" and "client".
How would the abstract client/server be setup?
I haven't used p2pt, but after a quick look over the docs, i think it can work if you clone the ws transport module and implement the p2pt library over it. The only small issue i can see is with the tracker connection, but i think it's possible to implement it in the transport module.
I need to look over the library a bit more, but at first glance, it should be doable
cool, any pointers would be great.
PR's are welcome 😄
The concept of anysocket is simple, and hopefully enough. Everything is based on a transport layer/module, which you can find the code for here
The Peer is a client and the Transport is the network protocol.
The Peer can send a message and emit connect/disconnect messages.
The Transport is how you define the connection, or how you discover peers.
Now, if you want to implement the p2pt library, what you need to do is to implement the Server creation / Discovery of peers in the transport layer and add/remove peers from there.
The new Peer(socket) (look into the ws transport module), the socket is anything you want, and it should be something that can be used to send a message over that protocol.