In Web Wallets Using Copay and Scalable Multi-Signature Web Wallets With Copay we explained how to multiplex Copay connections to form a single BitPay Insight server connection so you could easily scale an online web wallet service based on BitPay open source software. Copay has since been modified to use interesting new components: Bitcore Wallet Service (BWS) and Bitcore Wallet Client. The Bitcore Wallet Client makes it easy to manage multi-signature wallets. However, the client only handles one wallet at a time. If you want to use more than one wallet at a time you must instantiate different clients, each of which uses a different network connection. To get around this new issue and multiplex the connections we have modified BWS and Bitcore Wallet Client.
First, we decoupled the client API class from the physical network socket in the Bitcore Wallet Client. This is transparent to the user of the library. Then we modified the way messages are routed between sockets in the Bitcore Wallet Service to allow more than one wallet per connection. We have submitted two pull requests to integrate these modifications into the BWS and Bitcore Wallet Client: