code: def withHeartbeater(cls, heartbeater):
          
          instance = cls(heartbeater)
          heartbeater.writeHeartbeat = instance.heartbeat
          return instance
docs: Connect a SockJSProtocolMachine to its heartbeater.