Let's learn how to get a simple chat server up and running without writing any code. The next chapter, ‘Plugins’, will dive deeper into how to create a plugin.
Open a shell (terminal window) and start YAKjs with:
Now, YAKjs is running and uses this ports:
Provides the user interface and the REST API.
A chat WebSocket endpoint
Start your favorite browser and open the YKAjs user interface at http://localhost:8790
The first page
Instances provides a list of configured WebSocket server instances. Make sure that the chat service is started.
To test if the chat server is working, let's us the websocket.org echo client
We can connect to our local WebSocket chat instance on ws://localhost:9020. Now you can write a text and send it.
The echo plugin sends back the received message. The send text is displayed in the log area.
If you don't like to see your own messages, open the YAKjs user interface and configure the
chat instance and disable the echo plugin.
Stop and start the
chat instance so that your configuration will apply.
When you stop an instance all connected clients will be disconnected. You can see a
DISCONNECTED message in the log.
The broadcast plugin sends the received message to every connected client, but not back to the sender. Let's open a second websocket.org echo client and also connect it to ws://localhost:9020, now we have two clients and the chat can start.
The broadcast plugin is great for every publish to all clients use case.
Congrats! We have our chat system up and running. Keep in mind that YAKjs is a tool for prototyping, simulation and testing. It is not designed to be used in a production environment, even if it is very stable and reliable.
With this tutorial you have learned:
chatis a WebSocket instance running on port 9020
chatuses two plugins echo and broadcast