Refactor to have client and server interface

Change-Id: I6d8de247b2b38c60db4a8c29466b3ce545d09ccc
Reviewed-on: http://review.couchbase.org/28922
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>