![]() |
|
Don't ask to ask, just ask | |
PerlMonks |
mojo::websocket reconnectby james28909 (Deacon) |
on May 19, 2022 at 17:49 UTC ( #11144015=perlquestion: print w/replies, xml ) | Need Help?? |
james28909 has asked for the wisdom of the Perl Monks concerning the following question: I am having some difficulty trying to understand how to reconnect this websocket. I have a simple discord bot that i am using to provide services to users at a website i moderate. Everything works as expected except when the gateway operation code '7' (server requests reconnect) is sent to my client. To reconnect/resume a connection, you must send session id, token and sequence number of the last event. I have all of this info already and am not to sure about how to reconnect/resume the websocket connection. I would ask at discord api chat but this isnt a discord problem, its a me not knowing how to reconnect with the lib i am using problem lol. EDIT: Before this code there are a POST and a GET request sent to their servers for authorization and logging the bot in. When i do this i get the session_id and token. those two values are stored in a %globals hash and accessed when needed to reconnect. here is a snippet from my script:
The code is not a drop in place and work kind of thing. There could be syntax errors but hopefully this gets the point across of what i am trying to figure out. I just cant figure out how to reconnect. here are links to their api reference and i am pretty sure i have the payload setup right, I just dont know how to reconnect this websocket when requested. resume structure sent by client to server to reconnect
Back to
Seekers of Perl Wisdom
|
|