byte-stream icon indicating copy to clipboard operation
byte-stream copied to clipboard

Add async readline/echo and add composer commands

Open danog opened this issue 6 years ago • 5 comments

danog avatar Jul 15 '19 14:07 danog

Thanks, I was missing something akin to readLine just yesterday (just on a TCP socket to be used via telnet) ... But there's a catch: you are throwing away everything but the first line.

:-/

This is just a bit stupid due to that we have absolutely no buffering in out ResourceOutputStream. Is just sort of ... too primitive. Even on the kernel level you have the possibility to peek at the input stream and decide how much you want to consume (recv(MSG_PEEK)). But here this is not trivially possible.

It feels to me that there is fundamental functionality lacking here.

bwoebi avatar Jul 25 '19 10:07 bwoebi

Actually, I'm not throwing away anything because the other lines are being buffered in a static variable that persists after the function exits. I, too, encountered some issues when working with non-file AMP streams, which is why I created my own incremental async stream APIs, with buffered wrappers, hashing proxies, generic proxies. I intend to separate the stream and loop APIs of MadelineProto soon, so you can use them without including the entire project.

In the meantime you can try fiddling around with them if you like.

danog avatar Jul 25 '19 13:07 danog

@bwoebi I don't think these need to be on the basic interface. While they're sometimes needed, they can be provided by wrappers.

kelunik avatar Jul 25 '19 16:07 kelunik

We could include an implementation similar to https://github.com/kelunik/streaming-json/blob/c8b5bb9f65c67c0ca1fd2771ef00332c4c8ffe93/src/StreamingJsonParser.php, which doesn't do the JSON decoding and allows for customization of the line ending.

kelunik avatar Jul 25 '19 16:07 kelunik

Ping?

danog avatar Dec 13 '19 01:12 danog

This is something we see out of scope of this package, so I'm closing this. It hasn't received much attention in the last 4 years.

kelunik avatar Nov 19 '23 14:11 kelunik