For each file, the code should follow the single responsibility principle, if possible.
While working on the JSDoc standardization along the project, I found it very hard to document wsRPC.js, as it is mixing different classes and approaches.
version: 1.0.0
@Tschakki I was discussing this with @MaciejBaj, I also think this logic should be refactored. It's currently hard to follow and document. Some of the code in here deals with lost connections and making sure that the connection is reestablished before making RPC calls. This aspect could be handled by SocketCluster itself.
Right now, Lisk's peer-to-peer RPC is implemented using a low-level socket.send() method offered by SocketCluster; this isn't ideal because it means that connection failure and recovery, buffering, etc... has to be handled explicitly on our end inside the Lisk code. If we used SC's socket.emit() method instead, then it will automatically handle buffering and connection failure detection for us so it should simplify this logic a lot.
To clarify - the opened issue means for me "extract the logic of 'wsRPC.js' into separate files".
@jondubois's comment of using socket.emit() instead of socket.send() will remain changes in the corresponding code of wamp-socket-cluster library, which interacts only with raw events emitted while using socket.send(). It should be tackled as a separate issue with the corresponding one opened on wamp-socket-cluster library.
Please do as you've described then @MaciejBaj. Thanks.
Will be closed by #1472
Most helpful comment
To clarify - the opened issue means for me "extract the logic of 'wsRPC.js' into separate files".
@jondubois's comment of using
socket.emit()instead ofsocket.send()will remain changes in the corresponding code ofwamp-socket-clusterlibrary, which interacts only withrawevents emitted while usingsocket.send(). It should be tackled as a separate issue with the corresponding one opened onwamp-socket-clusterlibrary.