Add handlers for read/write operations and fix bug on self.sendMessage