webRTC Text Chat - Project, PeerConnection, and Handshaking set up

chat, webrtc, websocket

Solution

Since I'm not interested in audio/video I don't have to worry about STUN or TURN right? These are only required to handle sending media correctly?

You might need STUN and TURN. WebRTC establishes direct peer-to-peer communications and that's usually difficult or impossible without at least a STUN server, sometimes a TURN server.

Can I use just WebSockets to accomplish the complete handshaking process?

You will need to provide some way of getting messages from browser A to browser B. The usual method is to use a web server and either WebSockets, or sometimes HTTP.

Can I accomplish this project without having to have any sort of server?

No. You could send HTML and Javascript to clients using floppy disks, but in order to setup the peer-to-peer communications, you will need something that is able to transfer messages between clients in near-real time. That's usually a server. (I've seen demos using email, or copy-paste, but those are brittle.

Problem

Goal: Create a very basic text chat room on a web page using `webRTC` (no video or audio). To begin with I'm not concerned about creating chat rooms, having usernames, or supporting numerous connections. I'd just like to get it set up to support the first 2 people to go to the web page so that they can send/view messages. Basically I'd want to create something very similar to this nice demo, except enable 2 people to talk to each other instead of only talking to yourself. Plan: I plan on using a free web hosting site to obtain a free domain and upload my `.html`, `.js`, and `.css` files to. This I've already done. I don't want to use any support libraries for setting up the connections since I'm doing this as a learning experience. From what I understand these things need to happen to make this work. A `PeerConnection` needs to be established. Handshaking needs to happen to open the `PeerConnection`. And a `DataChannel` needs to be opened to send the actual messages. Questions/Concerns: Since I'm not interested in audio/video I don't have to worry about `STUN` or `TURN` right? These are only required to handle sending media correctly? Can I use just `WebSockets` to accomplish the complete handshaking process? Can I accomplish this project without having to have any sort of server? All of the tutorials/demos that I've looked at haven't explicitly had text chat (with connecting to other people) so that's why I'm not sure if not having audio/video will allow me to do this like I want to. I appreciate any help given. I'm not looking for code, I'm trying to define my project layout. If anything I've mentioned here is wrong or won't work please let me know!

Original source