Athena WS Chat
Usage
- clone
- install shards
crystal run src/start.cr- Open
localhost:3000in 2 tabs recommended side-by-side - Enter a message in 1 and watch the other tab
Note: Chat does not persist. Refreshing will remove the text nodes.
About
Note: Firefox is finicky with websockets especially when you are refreshing. It can take upto 30 seconds for the connection to open. Watch the network tab for a 101 status code with file path
cable.
Crystal
-
Uses a forked version of athena found here
- Added the
upgrade_handlerproperty inART::Response
- Added the
-
All
cable.crcode is insrc/websocketsbut there is also a listener. -
Connections & messages are logged so feel free to look at your terminal.
Javascript
-
Code for frontend is in
index.js -
You will see an
actioncable.jsfile. That's a npm package. We have no bundler so i copied & pasted the code. Ideally you would just dorequire('actioncable')in yourindex.jsfile. -
Connections & messages are logged so feel free to look at your console.