message handling in client and server