implement data-upcall and state upcall