4

我正在使用 OpenTok 构建一个视频聊天网站。我可以进行视频和文本聊天(仍在进行屏幕共享),但我想知道是否有人可以为我指出有关文件共享的正确方向?

我希望双方能够相互发送文件,但不确定如何去做。可以使用Peer5吗?

4

1 回答 1

4

There are several ways to get the peers to send files to each other.

A first way is to upload the file to your server or to some cloud storage service. Then share the link to the other peers via OpenTok's Signaling API (which is, presumably, an abstraction over WebRTC's DataChannels). This solution is simple, but not peer-to-peer.

Another solution is to, again, upload the file to a server and share the link to the other peers, but this time have the peers download the file via Peer5's Downloader. The Peer5 Downloader uses a coordination server to figure out which peers are available to help with the download. If no peers are available, the download will fall back to the HTTP server. This of course only makes sense if the file is being shared with several peers at the same time. In 1-to-1 communications it is pointless.

The previous solution is P2P only in the download part; the user still has to upload the file to a server. Another way, which would be P2P all the way, is to cut the file into chunks, and send them over the OpenTok Signaling API. It is a complicated process but there are several tutorials about this. The tutorials use the WebRTC DataChannel, but it is reasonable to assume that they could be adapted to the Signaling API:

A interesting open source application of a file sharing app using WebRTC is Sharefest, made by the guys from Peer5. You can use it for inspiration if you are inclined to make such a system.

As a side note, OpenTok seems to be considering to build a starter kit with sample code about how to integrate OpenTok with Peer5 in a file sharing application. I do not know how such an implementation will work, but I presume it is some variation of my second suggestion here. It could be good to keep an eye on it.

于 2015-02-15T23:29:51.143 回答