You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code shared on Roku Community Slack by Chad Michael:
Out of curiosity, I checked it out just now and it does indeed seem to work with wss. I just added ws.Open() to the sample above and gave it an ngrok'd wss url to a local socket server and sure enough, it hit it. Listening to the port you get a roWebSocketEvent msg object. But not sure what methods are on it to get response details, all I found that worked was msg.GetInfo() but its kinda useless. Would be awesome if Roku would document this for us. Even if there were "limitations" it would be huge to have wss socket handling!
subMain()
port=CreateObject("roMessagePort")
ws=CreateObject("roWebSocket")
ws.SetMessagePort(port)
url="wss://78da1027bfb4.ngrok.app/sockets"ws.SetUrl(url)
ws.Open()
connected=false' wait for the socket to openwhiletruemsg=wait(0, port)
iftype(msg) ="roWebSocketEvent"thenifmsg.GetType() =1thenprint"Socket Openned: "; msg.GetInfo()
connected=trueexit whileelseprint"Failed to get Open signal. Got type: "+msg.GetType().ToStr(); msg.GetInfo()
exit whileendifendifendwhileifconnected=truethenws.Send("Hello World")
' wait for message responsewhiletruemsg=wait(0, port)
iftype(msg) ="roWebSocketEvent"thenifmsg.GetType() =4thenprint"Pending response "; msg.GetInfo()
else ifmsg.GetType() =5thenprint"Got Response: "; msg.GetInfo()
res=msg.GetInfo().text
? reselseprint"Unknown Type: "+msg.GetType().ToStr(); msg.GetInfo()
endifendifendwhileendifend sub
The text was updated successfully, but these errors were encountered:
Code shared on Roku Community Slack by Brahim Hadriche
Code shared on Roku Community Slack by Chad Michael:
The text was updated successfully, but these errors were encountered: