The crmakioma.messaging.SocketConnection class is used to encapsulate every socket communication. The class provides methods, for connect, disconnect, seting global listeners and functionalities like showMessage, openContainer and others.
SocketConnection Helper class
A helper class is provided by the SWAT framework in order to easily emit events, add event listeners or to check if connection was established successfully.
Code Block | ||
---|---|---|
| ||
const isConnected:boolean = akioma.SocketConnectionHelper.isConnected();
if(isConnected) {
akioma.SocketConnectionHelper.emit('openScreen', { name: 'offerw' });
} |
Code Block | ||
---|---|---|
| ||
akioma.SocketConnectionHelper.on('openScreen', (payload:any) => {
if(payload.name) {
akioma.swat.App.loadScreen({ containerName: payload.name });
}
}); |
Ui-connector routes:
Code Block | ||
---|---|---|
| ||
var controller = require('../controllers/ui-connector'); router.get('*', controller.all); |
...
This URL will emit an "openContainer" event for the user axadmin and open the offerNewG container. The crm.messaging.SocketConnection have a method called "setUpGlobalListeners" which set various listeners on akioma.socket, inclusive openContainer listener.
Treegrid socket functionality:
...
The node.js will listen on the room event and check the action. If it's "join", perform an socket.join room and emit an event "room_{data.name}" with the action and the coresponding user. Swat-webui listen to that event and call a treeRoomNotification saying that someone joined or leaved.
. The notification will be visible only if 2 different users work on the same treegrid.