Adding client and server heartbeat monitoring for streams.

maybe this function needs a different name? It doesn't seem to be the equivalent of `write_heartbeat`