def METHOD_NAME(self, ref, path, data, type_):
    ws = self.ref_to_ws.get(ref, None)
    if type_ == 'tunnel_close':
        if ws is not None:
            ws.close()
        return
    if ws is None:
        self.connect_octoprint_ws(ref, path)
        time.sleep(1)  # Wait to make sure websocket is established before `send` is called
    if data is not None:
        ws.send(data)