https://cs.ucsb.edu/~vigna/publications/2004_vigna_MDM04.pdf
import { Broker, Environment } from 'es.move';
const environment = new Environment('stage',
new Broker('http://localhost:4815'));
environment.connect(function () {
/* I do nothing! :) */
});import { Broker, Environment } from 'es.move';
const environment = new Environment('stage',
new Broker('http://localhost:4815'));
environment.connect(function () {
environment.run(function () {
let onePlusOne = 1 + 1;
console.log(`One plus one equals ${onePlusOne}`);
});
});import { Broker, Environment } from 'es.move';
const environment = new Environment('stage',
new Broker('http://localhost:4815'));
environment.connect(function () {
environment.run(function () {
console.log('Ready for agents!');
});
});import { Broker, Environment } from 'es.move';
const environment = new Environment('i_have_agents',
new Broker('http://localhost:4815'));
environment.connect(function () {
environment.run(function () {
console.log("This will print where I start...");
this.move('stage', function () {
console.log("And this will print where I move to!");
});
});
});import { Broker, Environment } from 'es.move';
const environment = new Environment('stage',
new Broker('http://localhost:4815'));
environment.connect(function () {
environment.run(function () {
console.log('Ready for agents!');
});
});import { Broker, Environment } from 'es.move';
const environment = new Environment('i_have_agents',
new Broker('http://localhost:4815'));
environment.connect(function () {
environment.run(function () {
let message = 'Hello from i_have_agents!';
this.move('stage', function () {
console.log(this.params.message);
}, { message });
});
});import { Broker, Environment } from 'es.move';
const environment = new Environment('i_have_agents',
new Broker('http://localhost:4815'));
let randomArray = (length, max) => [...new Array(length)]
.map(() => Math.round(Math.random() * max));
let getAverage = function (list) {
return this.away('stage', function () {
let sum = this.params.list.reduce((b, a) => a += b );
return sum / this.params.list.length
}, { list });
};
environment.connect(function () {
environment.run(function () {
let inputData = [100, 200, 50, 20].map((x) => randomArray(1000, x));
let agents = inputData.map(getAverage.bind(this));
this.join(agents).then((results) => {
console.log(results);
});
});
});const environment = new Environment('my_data',
new Broker('http://localhost:4815'));
environment.registerService('myDataService', {
getMyData: () => {
return 'Some Data';
}
});
environment.connect();const environment = new Environment('i_store_data',
new Broker('http://localhost:4815'));
let dummyDataStore = new Map();
environment.registerService('dataStore', dummyDataStore);
environment.connect(function () {
environment.run(function () {
this.away('my_data', function () {
let someData = this.$.myDataService.getMyData();
}).then((data) => {
this.$.dataStore.set('myData', data);
});
});
});const environment = new Environment('web_browser',
new Broker('http://chatroom.com'));
let submit = document.querySelector('#submit');
let input = document.querySelector('#input');
let messageLog = document.querySelector('#messageLog');
environment.registerService('messageLog', messageLog);
environment.connect(function () {
submit.onclick = function () {
environment.run(function () {
let message = input.text();
this.move('web_browser:all', function () {
this.$.messageLog.innerHTML += `<br>${message}`;
}, { message });
});
};
});
<html>
<head>
<script src='/es.move.js'/>
</head>
<body>
<div id='messageLog'/>
<input id='input' type='text'>
<input id='submit' type='submit'>
</body>
</html>const environment = new Environment('malicious',
new Broker('http://localhost:4815'));
// Kill All Stages
environment.connect(function () {
environment.run(function () {
this.move('stage:all', function () {
process.exit();
})
});
});
const environment = new Environment('malicious',
new Broker('http://localhost:4815'));
// Fork Bomb!
let forkBomb = function () {
this.move('stage', function () {
new Array(100000);
this.params.forkBomb();
}, { forkBomb: this.params.forkBomb });
this.move('stage', function () {
new Array(100000);
this.params.forkBomb();
}, { forkBomb: this.params.forkBomb });
}
environment.connect(function () {
environment.run(function () {
this.move('stage', forkBomb.bind(this), { forkBomb });
});
});