refactoring of web sockets communication using JSON serialization
instead of parsing strings