Two comments about the file...
1. Move the certificate exchange to another file as it has nothing to do with PZP websocket and is about certificate exchange between PZP..
2. Why are you sending all message to all connected webApps