I am playing around with B4J Websocket programming. (Trying a multipage app, using WebAppHelloWorld as the basis)
How can I pass parameters (either GET or POST) to my my handler?
I tried a simple get request:
and tried to extract the search query from Websocket.UpgradeRequest.ParameterMap, only to receive an empty map.
Looking at b4j_ws.js I saw that the search query is not passed on to the web socket.
The original line in b4j_ws.js reads:
Which I modified to include the search query
Now the search query gets passed on to the handler, but if I look at the ParameterMap, it contains the proper keys, but the values are java.lang.String objects.
I have no idea what to with these in B4J.
Questions:
Is there another way of passing query parameters without modifying b4j_ws.js?
If I do modify it, how do I handle the java.lang.String?
Can I pass the parameters of a POST request?
Am I doing it all wrong and should go hide in a corner?
How can I pass parameters (either GET or POST) to my my handler?
I tried a simple get request:
B4X:
http://192.168.1.106:51042/?a=1&b=2
and tried to extract the search query from Websocket.UpgradeRequest.ParameterMap, only to receive an empty map.
Looking at b4j_ws.js I saw that the search query is not passed on to the web socket.
The original line in b4j_ws.js reads:
B4X:
fullpath = ((l.protocol === "https:") ? "wss://" : "ws://") + l.hostname + ":" + l.port + absolutePath;
Which I modified to include the search query
B4X:
fullpath = ((l.protocol === "https:") ? "wss://" : "ws://") + l.hostname + ":" + l.port + absolutePath + l.search;
Now the search query gets passed on to the handler, but if I look at the ParameterMap, it contains the proper keys, but the values are java.lang.String objects.
B4X:
'result of Log(WebSocket1.UpgradeRequest.ParameterMap)
(MyMap) {b=[Ljava.lang.String;@169e486, a=[Ljava.lang.String;@184a0b7}
I have no idea what to with these in B4J.
Questions:
Is there another way of passing query parameters without modifying b4j_ws.js?
If I do modify it, how do I handle the java.lang.String?
Can I pass the parameters of a POST request?
Am I doing it all wrong and should go hide in a corner?