playground: update playground test to use explicit clients and servers.
MultiPart: 3/3
Change-Id: I2278eb6728caf005e03907becc251c37cf450b03
diff --git a/client/bundles/fortune/ex0-js/client.js b/client/bundles/fortune/ex0-js/client.js
index 70d9d1e..b4c25cf 100644
--- a/client/bundles/fortune/ex0-js/client.js
+++ b/client/bundles/fortune/ex0-js/client.js
@@ -1,5 +1,4 @@
var veyron = require('veyron');
-var context = veyron.context;
/**
* Create a Vanadium runtime using the configuration defined in config.js,
@@ -8,9 +7,10 @@
veyron.init(function(err, rt) {
if (err) { return error(err); }
- var ctx = new context.Context();
+ var ctx = rt.getContext();
+ var client = rt.newClient();
- retryBindTo(ctx, rt, function(err, fortuneService) {
+ retryBindTo(ctx, client, function(err, fortuneService) {
if (err) { return error(err); }
fortuneService.getRandomFortune(ctx, function(err, fortune) {
@@ -22,13 +22,13 @@
});
});
-function retryBindTo(ctx, rt, cb) {
- rt.bindTo(ctx, 'bakery/cookie/fortune', function(err, fortuneService) {
+function retryBindTo(ctx, client, cb) {
+ client.bindTo(ctx, 'bakery/cookie/fortune', function(err, fortuneService) {
if (err) {
console.error(err + '\nRetrying...');
// Try again in 100ms
return setTimeout(function() {
- retryBindTo(ctx, rt, cb);
+ retryBindTo(ctx, client, cb);
}, 100);
}
diff --git a/client/bundles/fortune/ex0-js/server.js b/client/bundles/fortune/ex0-js/server.js
index a4c2263..d263e6d 100644
--- a/client/bundles/fortune/ex0-js/server.js
+++ b/client/bundles/fortune/ex0-js/server.js
@@ -39,8 +39,9 @@
// Create a Vanadium runtime using the configuration
veyron.init().then(function(rt) {
+ var server = rt.newServer();
// Serve the fortune server under a name. Serve returns a Promise object
- rt.serve('bakery/cookie/fortune', fortuneService).then(function() {
+ server.serve('bakery/cookie/fortune', fortuneService).then(function() {
console.log('Fortune server serving under: bakery/cookie/fortune \n');
}).catch(function(err) {
console.error('Failed to serve the fortune server because: \n', err);
diff --git a/testdata/src/ping/ping.js b/testdata/src/ping/ping.js
index 6b8129e..6a09f5d 100644
--- a/testdata/src/ping/ping.js
+++ b/testdata/src/ping/ping.js
@@ -1,12 +1,11 @@
var veyron = require('veyron');
-var context = veyron.context;
veyron.init(function(err, rt) {
if (err) throw err;
- var ctx = new context.Context();
+ var ctx = rt.getContext();
- rt.bindTo(ctx, 'pingpong', function(err, s) {
+ rt.newClient().bindTo(ctx, 'pingpong', function(err, s) {
if (err) throw err;
s.ping(ctx, 'PING', function(err, pong) {
diff --git a/testdata/src/pong/pong.js b/testdata/src/pong/pong.js
index 8a5e3d8..7acbd3e 100644
--- a/testdata/src/pong/pong.js
+++ b/testdata/src/pong/pong.js
@@ -10,7 +10,7 @@
veyron.init(function(err, rt) {
if (err) throw err;
- rt.serve('pingpong', pingPongService, function(err) {
+ rt.newServer().serve('pingpong', pingPongService, function(err) {
if (err) throw err;
});
});