|
|
@@ -6,7 +6,16 @@ namespace Astralis {
|
|
|
public interface AsyncOutput : Object {
|
|
|
|
|
|
public abstract async void write(BinaryData data) throws Error;
|
|
|
- public abstract async void write_stream(InputStream stream) throws Error;
|
|
|
+ public virtual async void write_stream(InputStream stream) throws Error {
|
|
|
+ uint8[] chunk = new uint8[8192];
|
|
|
+ while (true) {
|
|
|
+ ssize_t bytes_read = yield stream.read_async(chunk);
|
|
|
+ if (bytes_read <= 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ yield write(new ByteBuffer.from_byte_array(chunk));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|