encodeRequest method
return request message
Implementation
OutputStream encodeRequest() {
assert(header.type == MessageType.request);
// generate body first
final body = OutputStream();
{
body.writeInt(requestId!);
body.writeString(identity.toString());
// TODO: facet support
body.writeSize(0); // List<facet>
body.writeSize(0); // secure
body.writeString(operation); // operation
body.writeByte(operationMode.index);
body.writeContext(context);
}
final bodyByteLength = body.lengthInBytes;
// params
final paramsStream = OutputStream();
writeParams(paramsStream);
final int encapByteLength = paramsStream.lengthInBytes + 6;
final out = OutputStream();
// prepare header
out.writeHeader(
header.apply(size: headerSize + bodyByteLength + encapByteLength),
);
// body
out.writeBlob(body.finished());
out.writeEncapsulation(Encapsulation(
size: encapByteLength,
major: 1,
minor: 1,
));
out.writeBlob(paramsStream.finished());
return out;
}