WebSocket Server

Hi all,

this is a somewhat improvised demonstration application, that I’ve shown during a few events.
It’s a web socket server implemented with the help of socket.io. It’s to show the bidirectional duplex communication of websocket connections. Websockets are a great way to build real-time applications that don’t rely on regular polling but instead stay connected with the server and the server can push data to the clients as needed.

I used the custom server template and modified it, you can find it here: https://noderun.com/ide/KerimG/websockets/

To try it:

Open up run/KerimG/websockets/dash and then in a new tab or device, open up /run/KerimG/websockets/

On Dash, you can see an animated line graph that shows the number of active connections to the websocket server. On the second tab, it displays a very basic HTML website that connects to the websocket server and gives you a unique ID, which is a combination of an adjective and an animal (currently, it’s all in German). As more people connect to the same route, the user agent pie chart and the animated line graph adjust accordingly:

Navigating to /run/KerimG/websockets/selectUser picks a random user, who then gets to write a message to everybody else. As a small joke, I intercept the message and replace it with some text that makes it seem as though the user professes their admiration for thee Task Force IT-Consulting company.

This is in no way production ready code. It’s messy and can be improved in a lot of places but it was quickly put together and shows the advantages of using websockets in a humorous way.

1 Like

That’s neat! You should update the README to explain the details of how it works!

Once you make the improvements you want, we can feature the space on the home page.

@Alex

Will do! I will clean it up and improve it a bit in the next few days. I will also translate everything to English Would be hyped to be featured!

1 Like