class / function / send Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Guhl
Posts: 15
Joined: 29 May 2018, 01:12

class / function / send

14 Jun 2018, 06:11

I found a websocket and it works very good.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



open a new connection:
new conn_to_some_api("wss://api....")

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus




Code: [Select all] [Download] GeSHi © Codebox Plus

func123
{
do stuff
this.send(data)
}


What I'm trying to do is to run a function based on the server response and send new data to the server.
If I try to do "this.send(data)" from inside func123 nothing is happening but if I use a "return data" which brings me back to the OnMessage(Event) of the class its working. But I need to send the data from the func123 part as there are sometimes multiple things to send.
How may I achive this? Could anyone help me out?

Thanks!
Nightwolf85
Posts: 295
Joined: 05 Feb 2017, 00:03

Re: class / function / send  Topic is solved

14 Jun 2018, 08:05

Is func123() part of the conn_to_some_api class?

If it isn't then the this object doesn't exist inside, and so as a solution you could pass it as a parameter:
make the function be func123(obj) and use obj.send(data) to send the data (can probably still call it 'this' but that may be confusing since it wouldn't be in the class)

call it with: func123(this) from within your OnMessage(Event) function

---
If it is within the class then all you should need to do is call it using this:
this.func123() within the OnMessage(Event) function


Hope that made sense, let me know if you have any luck.
User avatar
Guhl
Posts: 15
Joined: 29 May 2018, 01:12

Re: class / function / send

14 Jun 2018, 10:46

Thank you :)
call it with: func123(this) from within your OnMessage(Event) function

Did the trick :)

Return to “Ask For Help”

Who is online

Users browsing this forum: imustbeamoron, jonjbm, tmplinshi and 9 guests