1
votes

I've seen this example with shared hosting and PHP.

https://github.com/nielsbaloe/webrtc-php

It shares audio/video peer-to-peer, supposedly. Supposedly it does so even on shared hosting, and supposedly, once the connection is established, it works peer-to-peer. How could I modify this to send text chat messages, instead of audio and video?

EDIT: In hindsight, this is probably not a good idea. Even if one pulled off peer-to-peer in a many-to-many situation, it isn't ideal because the expectation of text chats is that you can at least see the last 50-100 messages and not start fresh each time. That requires synchronized state management for all the peers at once, and there's no way to do that without a central server. And if that's the case, then WebRTC is not the best solution at all. Instead, utilize ordinary AJAX and implement any kind of simple server-side state management, such as RAM files, shared memory APIs (memcached, for instance), database tables, files, etc.

1

1 Answers

0
votes

For this you need to create a datachannel where you can send text data on peer-to-peer RTCPeerConnection.

You can take a reference from here