veyron/examples/boxes/android/src/boxesp2p - fix up to use new ipc.Serve.

Change-Id: I0a3e4af4fd7542ca0316fa5d157d987a948c2ffb
diff --git a/examples/boxes/android/src/boxesp2p/main.go b/examples/boxes/android/src/boxesp2p/main.go
index f2a1afe..52cd749 100644
--- a/examples/boxes/android/src/boxesp2p/main.go
+++ b/examples/boxes/android/src/boxesp2p/main.go
@@ -87,10 +87,17 @@
 	jMID C.jmethodID
 }
 
+type boxesDispatcher struct {
+	drawAuth, syncAuth     security.Authorizer
+	drawServer, syncServer ipc.Invoker
+	storeDispatcher        ipc.Dispatcher
+}
+
 type goState struct {
 	runtime       veyron2.Runtime
 	store         *storage.Server
 	ipc           ipc.Server
+	disp          boxesDispatcher
 	drawStream    boxes.DrawInterfaceServiceDrawStream
 	signalling    boxes.BoxSignalling
 	boxList       chan boxes.Box
@@ -130,6 +137,16 @@
 	C.callMethod(env, jni.jObj, jni.jMID, jBoxId, &jPoints[0])
 }
 
+func (d *boxesDispatcher) Lookup(suffix string) (ipc.Invoker, security.Authorizer, error) {
+	if strings.HasSuffix(suffix, "draw") {
+		return d.drawServer, d.drawAuth, nil
+	}
+	if strings.HasSuffix(suffix, "sync") {
+		return d.syncServer, d.syncAuth, nil
+	}
+	return d.storeDispatcher.Lookup(suffix)
+}
+
 func (gs *goState) SyncBoxes(context ipc.ServerContext) error {
 	// Get the endpoint of the remote process
 	endPt, err := inaming.NewEndpoint(context.RemoteEndpoint().String())
@@ -233,13 +250,15 @@
 		panic(fmt.Errorf("Failed runtime.NewServer:%v", err))
 	}
 	drawServer := boxes.NewServerDrawInterface(gs)
-	if err := srv.Register("draw", ipc.SoloDispatcher(drawServer, auth)); err != nil {
-		panic(fmt.Errorf("Failed Register:%v", err))
-	}
+	gs.disp.drawAuth = auth
+	gs.disp.drawServer = ipc.ReflectInvoker(drawServer)
 	endPt, err := srv.Listen("tcp", gs.myIPAddr+drawServicePort)
 	if err != nil {
 		panic(fmt.Errorf("Failed to Listen:%v", err))
 	}
+	if err := srv.Serve("", &gs.disp); err != nil {
+		panic(fmt.Errorf("Failed Register:%v", err))
+	}
 	if err := gs.signalling.Add(gs.runtime.TODOContext(), endPt.String()); err != nil {
 		panic(fmt.Errorf("Failed to Add endpoint to signalling server:%v", err))
 	}
@@ -319,28 +338,30 @@
 		panic(fmt.Errorf("LoadACL failed:%v", err))
 	}
 	auth := security.NewACLAuthorizer(acl)
-
-	// Register the services
-	if err = gs.ipc.Register("", storage.NewStoreDispatcher(gs.store, auth)); err != nil {
-		panic(fmt.Errorf("s.Register(store) failed:%v", err))
-	}
+	gs.disp.storeDispatcher = storage.NewStoreDispatcher(gs.store, auth)
 
 	// Create an endpoint and start listening
 	if _, err = gs.ipc.Listen("tcp", gs.myIPAddr+storeServicePort); err != nil {
 		panic(fmt.Errorf("s.Listen() failed:%v", err))
 	}
+	// Register the services
+	if err = gs.ipc.Serve("", &gs.disp); err != nil {
+		panic(fmt.Errorf("s.Serve(store) failed:%v", err))
+	}
 	gs.storeEndpoint = "/" + gs.myIPAddr + storeServicePort
 }
 
 func initSyncService(peerEndpoint string) {
 	peerSyncAddr := strings.Split(peerEndpoint, ":")[0]
 	srv := vsync.NewServerSync(vsync.NewSyncd(peerSyncAddr+syncServicePort, peerSyncAddr /* peer deviceID */, gs.myIPAddr /* my deviceID */, storePath, gs.storeEndpoint, 0))
-	if err := gs.ipc.Register("sync", ipc.SoloDispatcher(srv, nil)); err != nil {
-		panic(fmt.Errorf("syncd:: error registering service: err %v", err))
-	}
+	gs.disp.syncAuth = nil
+	gs.disp.syncServer = ipc.ReflectInvoker(srv)
 	if _, err := gs.ipc.Listen("tcp", gs.myIPAddr+syncServicePort); err != nil {
 		panic(fmt.Errorf("syncd:: error listening to service: err %v", err))
 	}
+	if err := gs.ipc.Serve("", &gs.disp); err != nil {
+		panic(fmt.Errorf("syncd:: error serving service: err %v", err))
+	}
 }
 
 func init() {