I have a scenario in which I’m intentionally sending a wrong message to a websocket and it returns me the right input; I need to parse and store the right input and use it across the application. But I can’t return it. Here’s what the code looks like right now:
rightmsg = WebSockets.open(url) do ws wrongmsg = generatewrongmsg() if writeguarded(ws, JSON3.write(wrongmsg) data, success = readguarded(ws) # parse data here return data end end
But it just returns a
HTTP.Messages.Response object. I can assign it to a global, but this block is not in a global scope; it’s inside a function and Julia doesn’t seem to have a way to capture a non-global, local variable. Any solution?