2017-09-19 06:07:07 +00:00
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
import EventEmitter from 'events';
|
|
|
|
|
2018-06-24 05:30:56 +00:00
|
|
|
// .on('_error')
|
|
|
|
// .on('data')
|
|
|
|
// .on('close')
|
2017-09-19 06:07:07 +00:00
|
|
|
class Bound extends EventEmitter {
|
|
|
|
|
2018-02-13 08:46:28 +00:00
|
|
|
_config = null;
|
2017-12-25 08:42:01 +00:00
|
|
|
|
2018-06-24 05:30:56 +00:00
|
|
|
_source = null;
|
|
|
|
|
|
|
|
_conn = null;
|
|
|
|
|
2018-07-22 09:04:08 +00:00
|
|
|
_destroyed = false;
|
|
|
|
|
2018-06-24 05:30:56 +00:00
|
|
|
constructor({ config, source, conn }) {
|
2017-12-25 08:42:01 +00:00
|
|
|
super();
|
2018-02-13 08:46:28 +00:00
|
|
|
this._config = config;
|
2018-06-24 05:30:56 +00:00
|
|
|
this._source = source;
|
|
|
|
this._conn = conn;
|
2017-12-25 08:42:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get remoteHost() {
|
2018-06-24 05:30:56 +00:00
|
|
|
return this._source.host;
|
2017-12-25 08:42:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get remotePort() {
|
2018-06-24 05:30:56 +00:00
|
|
|
return this._source.port;
|
2017-12-25 08:42:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get remote() {
|
|
|
|
return `${this.remoteHost}:${this.remotePort}`;
|
|
|
|
}
|
|
|
|
|
2017-09-19 06:07:07 +00:00
|
|
|
get bufferSize() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get writable() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-22 09:04:08 +00:00
|
|
|
get destroyed() {
|
|
|
|
return this._destroyed;
|
|
|
|
}
|
|
|
|
|
2017-09-19 06:07:07 +00:00
|
|
|
onBroadcast() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
write(buffer) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-26 13:39:00 +00:00
|
|
|
close() {
|
2017-09-19 06:07:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Inbound extends Bound {
|
|
|
|
|
|
|
|
_outbound = null; // set by relay
|
|
|
|
|
2018-07-05 10:27:47 +00:00
|
|
|
get name() {
|
|
|
|
return 'inbound';
|
|
|
|
}
|
|
|
|
|
2017-09-19 06:07:07 +00:00
|
|
|
setOutbound(outbound) {
|
|
|
|
this._outbound = outbound;
|
|
|
|
}
|
|
|
|
|
2018-01-14 14:19:49 +00:00
|
|
|
getOutbound() {
|
|
|
|
return this._outbound;
|
|
|
|
}
|
|
|
|
|
2017-09-19 06:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Outbound extends Bound {
|
|
|
|
|
2017-12-25 08:42:01 +00:00
|
|
|
_inbound = null; // set by relay
|
2017-09-19 06:07:07 +00:00
|
|
|
|
2018-07-05 10:27:47 +00:00
|
|
|
get name() {
|
|
|
|
return 'outbound';
|
|
|
|
}
|
|
|
|
|
2017-12-25 08:42:01 +00:00
|
|
|
setInbound(inbound) {
|
|
|
|
this._inbound = inbound;
|
2017-09-19 06:07:07 +00:00
|
|
|
}
|
|
|
|
|
2018-01-14 14:19:49 +00:00
|
|
|
getInbound() {
|
|
|
|
return this._inbound;
|
|
|
|
}
|
|
|
|
|
2018-06-24 05:30:56 +00:00
|
|
|
async connect() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-09-19 06:07:07 +00:00
|
|
|
}
|