Use VDL typed streams in pipe2browser, and change "veyron" to "vanadium"
everywhere.

Also fix button labels on redirect page.

Change-Id: I2211c7bca16d9d37295d4229456defa33ebb2641
diff --git a/Makefile b/Makefile
index 8513cb7..afb6cad 100644
--- a/Makefile
+++ b/Makefile
@@ -24,25 +24,28 @@
 	npm install
 	touch node_modules
 
-# Link a local copy of veyron.js.
-# TODO(nlacasse): Remove this and put veyron.js in package.json once we can get
+# Link a local copy of vanadium.js.
+# TODO(nlacasse): Remove this and put vanadium.js in package.json once we can get
 # it from npm
-browser/third-party/npm/veyronjs@0.0.1: node_modules
+browser/third-party/npm/vanadium@0.0.1: node_modules
 	cd $(VANADIUM_ROOT)/release/javascript/core && \
-	jspm link -y npm:veyronjs@0.0.1
+	jspm link -y npm:vanadium@0.0.1
 	cd browser && \
-	jspm install -y -link npm:veyronjs
+	jspm install -y -link npm:vanadium
 
 # Install JSPM and Bower packages as listed in browser/package.json from JSPM and browser/bower.json from bower
-browser/third-party: browser/third-party/npm/veyronjs@0.0.1 browser/package.json browser/bower.json node_modules
+browser/third-party: browser/third-party/npm/vanadium@0.0.1 browser/package.json browser/bower.json node_modules
 	cd browser && \
 	jspm install -y && \
 	bower prune && \
 	bower install
 	touch browser/third-party
 
+browser/services/vdl/index.js:
+	v23 run vdl generate --lang=javascript --js_out_dir=browser/services p2b/vdl
+
 # Bundle whole app and third-party JavaScript into a single build.js
-browser/build.js: $(JS_FILES) browser/third-party node_modules
+browser/build.js: $(JS_FILES) browser/services/vdl/index.js  browser/third-party node_modules
 	cd browser; \
 	jspm setmode local; \
 	jspm bundle app build.js
@@ -69,7 +72,7 @@
 	rm -rf browser/build.js
 	rm -rf browser/index.html
 	rm -rf browser/third-party
-	rm -rf go/bin
+	rm -rf go/{bin,pkg}
 	rm -rf node_modules
 
 .PHONY: start clean watch test
diff --git a/browser/config.js b/browser/config.js
index bd947ec..660e2dd 100644
--- a/browser/config.js
+++ b/browser/config.js
@@ -20,7 +20,7 @@
     "npm:event-stream": "npm:event-stream@3.2.2",
     "npm:humanize": "npm:humanize@0.0.9",
     "stream": "github:jspm/nodelibs-stream@0.1.0",
-    "veyronjs": "npm:veyronjs@0.0.1",
+    "vanadium": "npm:vanadium@0.0.1",
     "github:jspm/nodelibs-assert@0.1.0": {
       "assert": "npm:assert@1.3.0"
     },
@@ -57,7 +57,7 @@
       "path-browserify": "npm:path-browserify@0.0.0"
     },
     "github:jspm/nodelibs-process@0.1.1": {
-      "process": "npm:process@0.10.0"
+      "process": "npm:process@0.10.1"
     },
     "github:jspm/nodelibs-punycode@0.1.0": {
       "punycode": "npm:punycode@1.3.2"
@@ -369,7 +369,7 @@
       "stream": "github:jspm/nodelibs-stream@0.1.0"
     },
     "npm:timers-browserify@1.3.0": {
-      "process": "npm:process@0.10.0"
+      "process": "npm:process@0.10.1"
     },
     "npm:url@0.10.2": {
       "assert": "github:jspm/nodelibs-assert@0.1.0",
@@ -381,7 +381,7 @@
       "inherits": "npm:inherits@2.0.1",
       "process": "github:jspm/nodelibs-process@0.1.1"
     },
-    "npm:veyronjs@0.0.1": {
+    "npm:vanadium@0.0.1": {
       "assert": "github:jspm/nodelibs-assert@0.1.0",
       "bluebird": "npm:bluebird@2.9.8",
       "buffer": "github:jspm/nodelibs-buffer@0.1.0",
@@ -391,6 +391,7 @@
       "crypto": "github:jspm/nodelibs-crypto@0.1.0",
       "dgram": "github:jspm/nodelibs-dgram@0.1.0",
       "dns": "github:jspm/nodelibs-dns@0.1.0",
+      "domready": "npm:domready@1.0.7",
       "es6-shim": "npm:es6-shim@0.20.4",
       "eventemitter2": "npm:eventemitter2@0.4.14",
       "events": "github:jspm/nodelibs-events@0.1.0",
diff --git a/browser/services/p2b/vdl/index.js b/browser/services/p2b/vdl/index.js
new file mode 100644
index 0000000..0019658
--- /dev/null
+++ b/browser/services/p2b/vdl/index.js
@@ -0,0 +1,79 @@
+// This file was auto-generated by the vanadium vdl tool.
+var vdl = require('vanadium').vdl;
+
+
+
+
+
+
+module.exports = {};
+
+
+
+// Types:
+var _type1 = new vdl.Type();
+_type1.kind = vdl.Kind.LIST;
+_type1.name = "";
+_type1.elem = vdl.Types.BYTE;
+_type1.freeze();
+
+
+
+
+// Consts:
+
+
+
+// Errors:
+
+
+
+// Services:
+
+  
+    
+function Viewer(){}
+module.exports.Viewer = Viewer
+
+    
+      
+Viewer.prototype.pipe = function(ctx) {
+  throw new Error('Method Pipe not implemented');
+};
+     
+
+    
+Viewer.prototype._serviceDescription = {
+  name: 'Viewer',
+  pkgPath: 'p2b/vdl',
+  doc: "// Viewer allows clients to stream data to it and to request a\n// particular viewer to format and display the data.",
+  embeds: [],
+  methods: [
+    
+      
+    {
+    name: 'Pipe',
+    doc: "// Pipe creates a bidirectional pipe between client and viewer\n// service, returns total number of bytes received by the service\n// after streaming ends",
+    inArgs: [],
+    outArgs: [{
+      name: '',
+      doc: "",
+      type: vdl.Types.ANY
+    },
+    ],
+    inStream: {
+      name: '',
+      doc: '',
+      type: _type1
+    },
+    outStream: null,
+    tags: []
+  },
+     
+  ]
+};
+
+   
+ 
+
+
diff --git a/browser/services/pipe-to-browser-client.js b/browser/services/pipe-to-browser-client.js
index f2c43c7..fc99da8 100644
--- a/browser/services/pipe-to-browser-client.js
+++ b/browser/services/pipe-to-browser-client.js
@@ -1,21 +1,21 @@
 /*
- * Implements a veyron client that can talk to a P2B service.
+ * Implements a vanadium client that can talk to a P2B service.
  * @fileoverview
  */
 import { Logger } from 'libs/logs/logger'
-import veyron from 'veyronjs'
+import vanadium from 'vanadium'
 
 var log = new Logger('services/p2b-client');
 
 /*
  * Pipes a stream of data to the P2B service identified
- * by the given veyron name.
+ * by the given vanadium name.
  * @param {string} name Veyron name of the destination service
  * @param {Stream} Stream of data to pipe to it.
  * @return {Promise} Promise indicating if piping was successful or not
  */
 export function pipe(name, stream) {
-  return veyron.init().then((runtime) => {
+  return vanadium.init().then((runtime) => {
     var client = runtime.newClient();
     var ctx = runtime.getContext().withTimeout(5000);
     ctx.waitUntilDone(function(){});
diff --git a/browser/services/pipe-to-browser-namespace.js b/browser/services/pipe-to-browser-namespace.js
index df1a7c0..5ef32f1 100644
--- a/browser/services/pipe-to-browser-namespace.js
+++ b/browser/services/pipe-to-browser-namespace.js
@@ -1,10 +1,10 @@
 /*
- * Implements a veyron client that talks to the namespace service and finds all
+ * Implements a vanadium client that talks to the namespace service and finds all
  * the P2B services that are available.
  * @fileoverview
  */
 import { Logger } from 'libs/logs/logger'
-import veyron from 'veyronjs'
+import vanadium from 'vanadium'
 
 var log = new Logger('services/p2b-namespace');
 
@@ -14,7 +14,7 @@
  * P2B services
  */
 export function getAll() {
-  return veyron.init().then((runtime) => {
+  return vanadium.init().then((runtime) => {
     var namespace = runtime.namespace();
     var ctx = runtime.getContext().withTimeout(5000);
     ctx.waitUntilDone(function(){});
diff --git a/browser/services/pipe-to-browser-server.js b/browser/services/pipe-to-browser-server.js
index 6229d37..019774d 100644
--- a/browser/services/pipe-to-browser-server.js
+++ b/browser/services/pipe-to-browser-server.js
@@ -8,7 +8,8 @@
 import { ByteObjectStreamAdapter } from 'libs/utils/byte-object-stream-adapter'
 import { StreamByteCounter } from 'libs/utils/stream-byte-counter'
 import { StreamCopy } from 'libs/utils/stream-copy'
-import veyron from 'veyronjs'
+import vanadium from 'vanadium'
+import vdl from 'services/p2b/vdl/index'
 
 var log = new Logger('services/p2b-server');
 var server;
@@ -46,11 +47,16 @@
  */
 export function publish(name, pipeRequestHandler) {
   log.debug('publishing under name:', name);
+
   /*
    * Veyron pipe to browser service implementation.
    * Implements the p2b VDL.
    */
-  var p2b = {
+  class Service extends vdl.Viewer {
+    constructor() {
+      super();
+    }
+
     pipe(ctx, $stream) {
       return new Promise(function(resolve, reject) {
         log.debug('received pipe request for:', ctx.suffix);
@@ -94,11 +100,13 @@
         }
       });
     }
-  };
+  }
+
+  var p2b = new Service();
 
   state.publishing = true;
 
-  return veyron.init().then((runtime) => {
+  return vanadium.init().then((runtime) => {
     server = runtime.newServer();
     var serviceName = 'google/p2b/' + name;
 
diff --git a/go/src/p2b/vdl/p2b.vdl.go b/go/src/p2b/vdl/p2b.vdl.go
index d6ec0c5..72c2474 100644
--- a/go/src/p2b/vdl/p2b.vdl.go
+++ b/go/src/p2b/vdl/p2b.vdl.go
@@ -110,17 +110,17 @@
 	Send(item []byte) error
 	Close() error
 } {
-	return implViewerPipeCallSend{c}
+	return implViewerPipeClientCallSend{c}
 }
 
-type implViewerPipeCallSend struct {
+type implViewerPipeClientCallSend struct {
 	c *implViewerPipeClientCall
 }
 
-func (c implViewerPipeCallSend) Send(item []byte) error {
+func (c implViewerPipeClientCallSend) Send(item []byte) error {
 	return c.c.Send(item)
 }
-func (c implViewerPipeCallSend) Close() error {
+func (c implViewerPipeClientCallSend) Close() error {
 	return c.c.CloseSend()
 }
 func (c *implViewerPipeClientCall) Finish() (o0 *vdl.Value, err error) {
@@ -137,7 +137,7 @@
 	// Pipe creates a bidirectional pipe between client and viewer
 	// service, returns total number of bytes received by the service
 	// after streaming ends
-	Pipe(ViewerPipeContext) (*vdl.Value, error)
+	Pipe(ViewerPipeServerCall) (*vdl.Value, error)
 }
 
 // ViewerServerStubMethods is the server interface containing
@@ -148,7 +148,7 @@
 	// Pipe creates a bidirectional pipe between client and viewer
 	// service, returns total number of bytes received by the service
 	// after streaming ends
-	Pipe(*ViewerPipeContextStub) (*vdl.Value, error)
+	Pipe(*ViewerPipeServerCallStub) (*vdl.Value, error)
 }
 
 // ViewerServerStub adds universal methods to ViewerServerStubMethods.
@@ -180,8 +180,8 @@
 	gs   *ipc.GlobState
 }
 
-func (s implViewerServerStub) Pipe(ctx *ViewerPipeContextStub) (*vdl.Value, error) {
-	return s.impl.Pipe(ctx)
+func (s implViewerServerStub) Pipe(call *ViewerPipeServerCallStub) (*vdl.Value, error) {
+	return s.impl.Pipe(call)
 }
 
 func (s implViewerServerStub) Globber() *ipc.GlobState {
@@ -227,46 +227,46 @@
 	}
 }
 
-// ViewerPipeContext represents the context passed to Viewer.Pipe.
-type ViewerPipeContext interface {
+// ViewerPipeServerCall represents the context passed to Viewer.Pipe.
+type ViewerPipeServerCall interface {
 	ipc.ServerCall
 	ViewerPipeServerStream
 }
 
-// ViewerPipeContextStub is a wrapper that converts ipc.StreamServerCall into
-// a typesafe stub that implements ViewerPipeContext.
-type ViewerPipeContextStub struct {
+// ViewerPipeServerCallStub is a wrapper that converts ipc.StreamServerCall into
+// a typesafe stub that implements ViewerPipeServerCall.
+type ViewerPipeServerCallStub struct {
 	ipc.StreamServerCall
 	valRecv []byte
 	errRecv error
 }
 
-// Init initializes ViewerPipeContextStub from ipc.StreamServerCall.
-func (s *ViewerPipeContextStub) Init(call ipc.StreamServerCall) {
+// Init initializes ViewerPipeServerCallStub from ipc.StreamServerCall.
+func (s *ViewerPipeServerCallStub) Init(call ipc.StreamServerCall) {
 	s.StreamServerCall = call
 }
 
 // RecvStream returns the receiver side of the Viewer.Pipe server stream.
-func (s *ViewerPipeContextStub) RecvStream() interface {
+func (s *ViewerPipeServerCallStub) RecvStream() interface {
 	Advance() bool
 	Value() []byte
 	Err() error
 } {
-	return implViewerPipeContextRecv{s}
+	return implViewerPipeServerCallRecv{s}
 }
 
-type implViewerPipeContextRecv struct {
-	s *ViewerPipeContextStub
+type implViewerPipeServerCallRecv struct {
+	s *ViewerPipeServerCallStub
 }
 
-func (s implViewerPipeContextRecv) Advance() bool {
+func (s implViewerPipeServerCallRecv) Advance() bool {
 	s.s.errRecv = s.s.Recv(&s.s.valRecv)
 	return s.s.errRecv == nil
 }
-func (s implViewerPipeContextRecv) Value() []byte {
+func (s implViewerPipeServerCallRecv) Value() []byte {
 	return s.s.valRecv
 }
-func (s implViewerPipeContextRecv) Err() error {
+func (s implViewerPipeServerCallRecv) Err() error {
 	if s.s.errRecv == io.EOF {
 		return nil
 	}