writeTo method
Implementation
Future writeTo(Socket writer) async {
for (int i=0; i< this.raw.length; i++) {
Object input = this.raw[i];
if (i%2 == 0) {
writer.add(input as Uint8List);
} else {
int t = this.types[((i-1)/2).toInt()];
switch (t) {
case OUT_TYPE_BYTES:
writer.add(input as Uint8List);
break;
case OUT_TYPE_READER:
Stream reader = input as Stream;
Completer completer = Completer();
reader.listen((event) {
writer.add(event);
}, onError: (err){
throw err;
}, onDone: (){
completer.complete();
});
await completer.future;
break;
default:
break;
}
}
}
}