Fixed code with callback function randomString in WebSocket