You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
Add WS filtering using WS pool strategy. The idea is to support topic based communication over ws channel.
To achieve this, we need ws clients pooling mechanism where ws clients send subscribe message with the list of topics (ws.send({ type: 'subscribe', topic: 'app' })) and then the ws server adds these client sockets to corresponding topics as per the subscribe message sent by the client. Below is an idea for this strategy.
// At clientwsClientChannel.connect();wsClientChannel.on('app',handler());wsClientChannel.on('app:getNodeStatus',handler());// will call ws.send({ type: 'subscribe', topics: ['app',’block']})// BusconsttopicPool={// all registered topics'app': [clientSocket1,clientSocket2],'dpos': [clientSocket2,clientSocket5],}wsServer.on('connection',sock=>{// Broker registers the new client along with the topics subscribed and uses it to send wsServer.on('message',msg=>{if(message.type==='subscribe'){for(consttopicofmsg.topics){// subscribes the event for that client in brokertopicPool[topic].push(sock);}}})});publish(event,data){// iterate through peer Pool for the given event and send to clientsconsttopic=event.split(':')[0];for(constclientoftopicPool[topic]){client.send(data);}}
Acceptance Criteria
Unit tests under test/unit/controller/ws should pass
Add additional functional/integration/unit tests to verify topic based ws API communication
Description
Add WS filtering using WS pool strategy. The idea is to support topic based communication over ws channel.
To achieve this, we need
ws
clients pooling mechanism wherews
clients sendsubscribe
message with the list of topics (ws.send({ type: 'subscribe', topic: 'app' })
) and then thews
server adds these client sockets to corresponding topics as per thesubscribe
message sent by the client. Below is an idea for this strategy.Acceptance Criteria
test/unit/controller/ws
should passAdditional Information
The text was updated successfully, but these errors were encountered: