Closed caracal7 closed 5 years ago
Basically event on('message')
will intercept all messages as it is default websocket event, to process message u need to call inside of event on message socket.processMessage(message);
or completely remove on('message')
event.
For example
client
socket.on('message', async message => {
console.log('message', message);
socket.processMessage(message);
});
socket.on('myMsg', async data => {
console.log('data', data);
});
Main reason for that event is that you can set up your own protocol and modify data before passing it to socket.processMessage
in correct structure for ClusterWS to understand, or just to ignore / intercept / lookup some messages, also socket.processMessage
accepts 2 types of data first is array and second is string with array inside. The same rules apples for Server side.
All of that will be (should be) in documentation hopefully soon :)
Thanks for the quick response and for the great library!
With adding socket.processMessage(message);
or without socket.on('message',...);
everything working perfect!
I'm successfully migrated from 3.x to 4.0.0!
Server
Client