We improved the performance of the chat feature significantly by introducing a websocket interface to the REST and messaging API. By this architectural change it is now possible to send and receive chat messages instantly. Although the new chat is much faster it adds fewer load to the server which results in a performance improvement of the whole website.
Not only the performance was improved, there are a bunch of new features as well. The interface was newly designed to achieve a better usability too.
The Chat Message
Every message highlights if the sender is currently logged in and active or offline. It's now easily possible to quote a message by clicking on the quotation mark button.
The two buttons on the left can be used to file a complaint about the message and to delete the message. Whether you are allowed to delete a message or not depends on you having the ownership of the message (a.k.a. being the sender of it) or having the rights to delete messages in this particular chat.
Roles, Rights and Moderation
To enable chat moderation several roles have been added. The next role in the table includes all the rights of the roles above:
|Reader||Has the right to read a message and to file a complaint about it|
|Author||Has the right to send a message and delete it|
|Moderator||Has the right to delete a message of an other user and to remove him/her from the chat|
|Deputy||Has the right to change the role of a user, to add users to the chat and to change the chat itself|
|Owner||Owns the chat and has the exclusive right to delete it|
It is possible for a chat to have more than one owner.
List of Chats
The chat overview now shows some more information about the chat.
The eye indicates that it is a public chatroom. Public chatrooms can be seen by everyone and everyone can join them as he/she pleases. The next symbol indicates that it is a group chat. Every chat with more than two members is considered to be a group chat.
If you hover a chat a properties button appears. You can click on it to see or adjust the chat's properties and its members
Adding a new Chat
By clicking on "New Chat" it is possible to create a new chat.
You can optionally set a name which will appear in the chats list. It is possible to let the chat be writable by every member (Everyone can write) or to be readonly (Only me and privileged). In a readonly chat only owners and deputies are allowed to write. You can choose if you want the chat to be a private conversation or a public chatroom.
Adding Members and setting Roles
Once you have created a chat you can add other members and adjust their roles. The online status on every user is indicated on the username in the same way as it is indicated in chat messages. It is possible to adjust the role of existing members and to add members having a certain role. Additionally you can remove members from the chat. If you remove the (last) owner of a private chat it will be deleted. In a public chat the next most privileged user will become the owner.
Leaving/Deleting a Chat
If you enter the properties of a chat, you notice the button to leave or delete the chat.
By clicking on it two more buttons are expanded. They enable you to leave (take care if you are the (last) owner of a chat) or to to delete the chat.
If you click on "List of Chatrooms" a table with all public chatrooms will appear:
The table can be filtered by using the table's search field. It is sorted by number of members in descending order. You can join a chatroom by clicking on the "Join Chatroom" button.
It is also possible to look for chatrooms with a particular member:
"Lobby" is a special chatroom. Every new user joins it automatically.
The browser title indicates that unread chats exist.
Messaging all Shareholders of a Company
Every company profile features a new button to message all shareholders. By pressing it a new private readonly chat will be opened. It can be used to send ad-hoc messages or takeover bids and such to the shareholders.
For the API Users: The Websocket
It is now possible to access the API via Websockets. The UI shows the state of the websocket connection with the user icon on the top right of the website:
A grey user indicates that the websocket is connecting (can be seen a short time between page switchs), a green user icon shows an established websocket connection and the red one appears in case of a connection loss. A a connection loss can appear during a backend restart or while using an unreliable internet connection as for example while using a mobile phone. Even a disconnected websocket can send messages in the UI. They are cached until the the websocket connection is established again.
The Alpha-Trader websocket API is capable of accessing the whole REST API as well as subscribing to some special topics. Example:
Send "GET /api/v2/my/chats" to "/app/wsconsole/" to get all chats with the current users particpation. To receive the answer you have to subscribe to "/user/topic/wsconsole/" before(!) sending the message. Websockets are a subscribe-publish way of accessing in constrat to the request-response approach of a HTTP REST API access.
To establish a websocket connection connect to "https://<branch>.alpha-trader.com/ws" while branch being the name of the AT branch (dev, nightly or stable). To authorize against the backend connect with a STOMP header with the token "'Authorization' : 'Bearer ' + token".
Additionally to the wsconsole topic you can subscribe to the following special topics:
- /user/topic/my/chats - receives all changes of the chats with the logged in user's participation
- /user/topic/notifications - receives all new notifications of the user
- /user/topic/chatmessages/<chatId> - receives all changes of chat message of chat with id <chatId
In order to avoid mixing results of Console accesses, you can provide a unique identifier <consoleId>:
Subscribe to /user/topic/wsconsole/<consoleId> and send to /app/wsconsole/<consoleId>
Subscriptions to /user/ are always secured to only the user that subscribed it.