1 | var eve = require('../../index');
|
2 |
|
3 | function PatternAgent(id) {
|
4 |
|
5 | eve.Agent.call(this, id);
|
6 |
|
7 |
|
8 | this.extend('pattern');
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | this.listen(/hello/i, function (from, message) {
|
16 |
|
17 | this.send(from, 'Hi ' + from + ', nice to meet you!');
|
18 | });
|
19 |
|
20 |
|
21 | this.listen(/./, function (from, message) {
|
22 | console.log(from + ' said: ' + message);
|
23 | });
|
24 |
|
25 |
|
26 | this.connect(eve.system.transports.getAll());
|
27 | }
|
28 |
|
29 |
|
30 | PatternAgent.prototype = Object.create(eve.Agent.prototype);
|
31 | PatternAgent.prototype.constructor = PatternAgent;
|
32 |
|
33 | module.exports = PatternAgent;
|