Most of the code was taken from the article at https://stfalcon.com/en/blog/post/android-websocket - specifically from the Github repo mentioned in the article. I had to make some tweaks to get it to run in Android Studio.
The key element of the demo is how to make a secure web socket connection. This one works with a Mattermost server, like the one at https://enrico.teaches-yoga.com