-->
Page 2 of 2

Re: Multiple variables using a for statement? Server/STA Mod

PostPosted: Mon May 21, 2018 10:40 am
by mrlightsman
I've been working on this a bit over the weekend and am now giving serious thought to using websockets rather than udp to survey the status of my switches. The question is, "Can a sketch run two instances of websockets client at one time?"

My current switch sketch already uses
Code: Select allwebSocket.begin("somewhere.com", 80, "/");

and
Code: Select allwebSocket.onEvent(webSocketEvent)
;

Can it simultaneously use
Code: Select allwebSocket.begin("192.168.0.123", 81, "/");


Then handle both websockets events in my void(webSocketEvent)?

Re: Multiple variables using a for statement? Server/STA Mod

PostPosted: Mon May 21, 2018 4:13 pm
by btidey
I think you want to create 2 separate instances of the websocket client (e.g. websocket1 and websocket2)

You can then set them up separately and they will each have their own onEvent handler.

Re: Multiple variables using a for statement? Server/STA Mod

PostPosted: Wed May 23, 2018 6:45 am
by mrlightsman
That makes perfect sense! I will give it a go and report back. Thanks.