The two parts of code that you posted don't appear to go together. It does not look like there is any client command registered called "cmdaddxp".
It would be easiest if you attach your entire plugin. If you don't want to do that, create a test plugin with just the functionality that you are struggling with that reproduces the issue.