2011-02-24 09:50:43 +08:00
|
|
|
var helper = require(__dirname+'/../test-helper');
|
|
|
|
var EventEmitter = require('events').EventEmitter;
|
2011-08-29 15:35:08 +08:00
|
|
|
var Connection = require(__dirname + '/../../lib/connection');
|
2010-10-07 08:59:20 +08:00
|
|
|
MemoryStream = function() {
|
|
|
|
EventEmitter.call(this);
|
2010-10-07 10:34:51 +08:00
|
|
|
this.packets = [];
|
2010-10-07 08:59:20 +08:00
|
|
|
};
|
|
|
|
|
2012-05-31 11:40:49 +08:00
|
|
|
|
2011-02-24 09:50:43 +08:00
|
|
|
helper.sys.inherits(MemoryStream, EventEmitter);
|
2010-10-07 08:59:20 +08:00
|
|
|
|
|
|
|
var p = MemoryStream.prototype;
|
2010-10-08 09:00:49 +08:00
|
|
|
|
|
|
|
p.write = function(packet) {
|
|
|
|
this.packets.push(packet);
|
|
|
|
};
|
2010-10-20 11:58:25 +08:00
|
|
|
|
2016-06-22 03:49:41 +08:00
|
|
|
p.setKeepAlive = function(){};
|
|
|
|
|
2012-05-31 11:40:49 +08:00
|
|
|
p.writable = true;
|
|
|
|
|
2010-10-20 11:58:25 +08:00
|
|
|
createClient = function() {
|
|
|
|
var stream = new MemoryStream();
|
|
|
|
stream.readyState = "open";
|
|
|
|
var client = new Client({
|
2010-10-25 11:52:12 +08:00
|
|
|
connection: new Connection({stream: stream})
|
2010-10-20 11:58:25 +08:00
|
|
|
});
|
|
|
|
client.connect();
|
2010-10-20 12:02:33 +08:00
|
|
|
return client;
|
2010-10-20 11:58:25 +08:00
|
|
|
};
|
2011-07-20 05:55:39 +08:00
|
|
|
|
|
|
|
module.exports = helper;
|