Viewing a stream.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Viewing a stream.

Günther Schmidt
Hi,

is it possible to make a stream *visible*?

Like having a WriteStream (from a string) display in a Multiline Textedit?

I'm using the POP and SMTP Sockets package from Jose S. Calvo and I'd
like to *watch* what his package is writing to the TCP socket in a
multiline text view.

Günther


Reply | Threaded
Open this post in threaded view
|

Re: Viewing a stream.

Ian Bartholomew-19
Günther,

> is it possible to make a stream *visible*?
>
> Like having a WriteStream (from a string) display in a Multiline Textedit?
>
> I'm using the POP and SMTP Sockets package from Jose S. Calvo and I'd
> like to *watch* what his package is writing to the TCP socket in a
> multiline text view.

Can't you just use the Transcript? Modify the appropriate methods
(#nextPut, #nextPutAll, #sendByteArray or whatever) so that they also
send to the Transcript as well as the Stream.

I usually find it's better to always convert them to a printable hex
string first using something like ...

(aByte printStringRadix: 16) copyFrom: 4

... so that you don't get involved with non-printable characters.  You
will obviously have to inject spaces and crs to make it readable.

If you want a longer lasting record then put a Stream of your own in a
Global variable and copy any bytes sent to that.  You can then inspect
it at any time to see what has occurred.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Viewing a stream.

Ian Bartholomew-19
In reply to this post by Günther Schmidt
Günther,

> is it possible to make a stream *visible*?
>
> Like having a WriteStream (from a string) display in a Multiline Textedit?
>
> I'm using the POP and SMTP Sockets package from Jose S. Calvo and I'd
> like to *watch* what his package is writing to the TCP socket in a
> multiline text view.

Can't you just use the Transcript? Modify the appropriate methods
(#nextPut, #nextPutAll, #sendByteArray or whatever) so that they also
send to the Transcript as well as the Stream.

I usually find it's better to always convert them to a printable hex
string first using something like ...

(aByte printStringRadix: 16) copyFrom: 4

.. so that you don't get involved with non-printable characters.  You
will obviously have to inject spaces and crs to make it readable.

If you want a longer lasting record then put a Stream of your own in a
Global variable and copy any bytes sent to that.  You can then inspect
it at any time to see what has occurred.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Viewing a stream.

Günther Schmidt
In reply to this post by Ian Bartholomew-19
Ian,

Ian Bartholomew schrieb:

> Günther,
>
>> is it possible to make a stream *visible*?
>>
>> Like having a WriteStream (from a string) display in a Multiline
>> Textedit?
>>
>> I'm using the POP and SMTP Sockets package from Jose S. Calvo and I'd
>> like to *watch* what his package is writing to the TCP socket in a
>> multiline text view.
>
>
> Can't you just use the Transcript? Modify the appropriate methods
> (#nextPut, #nextPutAll, #sendByteArray or whatever) so that they also
> send to the Transcript as well as the Stream.

So it's not possible to attach an "inspecting view" on the stream or
monitor it directly, but I'd have to duplicate stream access?

>
> I usually find it's better to always convert them to a printable hex
> string first using something like ...
>
> (aByte printStringRadix: 16) copyFrom: 4
>
> ... so that you don't get involved with non-printable characters.  You
> will obviously have to inject spaces and crs to make it readable.
>
> If you want a longer lasting record then put a Stream of your own in a
> Global variable and copy any bytes sent to that.  You can then inspect
> it at any time to see what has occurred.
>

Günther


Reply | Threaded
Open this post in threaded view
|

Re: Viewing a stream.

Esteban A. Maringolo-2
Guenther Schmidt escribió:

>>> is it possible to make a stream *visible*?
>>> Like having a WriteStream (from a string) display in a Multiline
>>> Textedit?

>>> I'm using the POP and SMTP Sockets package from Jose S. Calvo and I'd
>>> like to *watch* what his package is writing to the TCP socket in a
>>> multiline text view.

>> Can't you just use the Transcript? Modify the appropriate methods
>> (#nextPut, #nextPutAll, #sendByteArray or whatever) so that they also
>> send to the Transcript as well as the Stream.

> So it's not possible to attach an "inspecting view" on the stream or
> monitor it directly, but I'd have to duplicate stream access?

Use events. That would trigger a lot of events, but it's the less
coupled way of doing what you want. Make a view listen to those
events, and update its contents. Or make a wrapper around the
stream, to decorate it, and trigger the events.


--
Esteban A. Maringolo
[hidden email]