Server change api

fix #337 

For convenience, this branch has been based on the issue_341 branch. 
This PR only shows the changes for the api change.
This needs to be updated.