Add in null protection for client/server sides of handleChat