var MAX_HTTP_PAYLOAD_SIZE = 16383;
Endpoint.prototype._initializeDataFlow = function _initializeDataFlow(role, settings) {
var firstStreamId, compressorRole, decompressorRole;
if (role === 'CLIENT') {
firstStreamId = 1;
compressorRole = 'REQUEST';
decompressorRole = 'RESPONSE';
} else {
firstStreamId = 2;
compressorRole = 'RESPONSE';
decompressorRole = 'REQUEST';
}
this._serializer = new Serializer(this._log, MAX_HTTP_PAYLOAD_SIZE);
this._deserializer = new Deserializer(this._log, MAX_HTTP_PAYLOAD_SIZE);
this._compressor = new Compressor(compressorRole, this._log);
this._decompressor = new Decompressor(decompressorRole, this._log);
this._connection = new Connection(firstStreamId, settings, this._log);
this._connection.pipe(this._compressor).pipe(this._serializer);
this._deserializer.pipe(this._decompressor).pipe(this._connection);
this._serializer.on('readable', this._read.bind(this));
};
Endpoint.prototype._read = function _read() {
var moreNeeded = true, chunk;
while (moreNeeded && (chunk = this._serializer.read())) {
moreNeeded = this.push(chunk);
}
};
Endpoint.prototype._write = function _write(chunk, encoding, done) {
this._deserializer.write(chunk, encoding, done);
};