Added working code for chat protocol