/**
* Created by Anna on 2017/11/30.
*/
//引入events模块
var events = require('events');
//创建eventEmitter对象
var eventEmitter = new events.EventEmitter();
//创建事件处理程序
var connectHandler = function connected() {
console.log('connect success!');
//触发data_received事件
eventEmitter.emit('data_received');
};
//绑定connection事件处理程序
eventEmitter.on('connection',connectHandler);
//使用匿名函数绑定data_received事件
eventEmitter.on('data_received',function () {
console.log('data connect success')
});
//触发connection事件
eventEmitter.emit('connection');
console.log('process end');