Tuesday, July 19, 2016

NetConnection, PeekableStream

I was able to finish up my AsyncMemoryStream today, and with it get my NetConnection class working in unit test. Pretty neat to see my application transport layer shuttling objects around over streams. However when I tried sending a non-trivial compound object, I immediately got a failure: the Seek method of my AsyncMemoryStream was being called, and wasn't implemented.

I could implement that method, but then I remembered that I shouldn't; you can't seek on a NetStream, so no seeking on AsyncMemoryStreams either. Being able to Seek (at least enough to peek 4 bytes at the end of a stream) is a required feature for my serialization layer. I remember (months and months ago), I decided I'd implement a PeekableStream to accommodate this whenever I got to the level of actually using my serialization code.

Well, the day has come. Spent rest of day working on a PeekableStream. You compose it with non seeking streams, and it provides a limited ability to seek back from END (just enough to peek something like a BinTag off the end).

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.