Page 1 of 1
Websockets call from javascript
Posted: 03 Feb 2018, 13:10
by metainilesh
Hello All,
I'm new here
I tried to call method newhttprequest using getapi() but it's always giving me error of getapi() is not defined.
Can anyone guide me how to call webmethods using websockets?
Thanks
Neel
Re: Websockets call from javascript
Posted: 05 Feb 2018, 08:20
by Lapo
Hi,
just to clarify are we talking about server side Javascript or client side?
I ask because you posted under the "Client API" section but getApi() is a method found in the server side.
Please clarify...
Thanks
Re: Websockets call from javascript
Posted: 05 Feb 2018, 12:30
by metainilesh
I'm talking about server side and below is my query
I have a below javascript server extension code
this below method i call it from the client side
function onGameDataRequest(params, sender) {
onhttpGameDataRequest();
response.putUtfString("resgamedata", resgamedata);
send("GameDataResponse", response, [sender]);
}
in this above method this below two lines are called instantly after onhttpgamedatarequest.
response.putUtfString("resgamedata", resgamedata);
send("GameDataResponse", response, [sender]);
I would like to call back after completion function httpGameDataCallback()
Like async or await or deffered in jquery we use i need something method sfs
[/b]Or something like async of httprequest or something status code i can get from httprequest object[/b]
function onhttpGameDataRequest() {
var reqParams;
var httpReq = getApi().newHttpGetRequest('http://someip/api/v1/user/getgamedata/57dd6105-b826-4f15-a247-9ae4bb6a9bed', reqParams, httpGameDataCallback)
httpReq.execute();
}
function httpGameDataCallback(result) {
if (result.error) {
resgamedata = result.error;
trace(result.error);
}
else {
resgamedata = result.html;
trace(result.html);
}
}