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
Websockets call from javascript
-
- Posts: 2
- Joined: 03 Feb 2018, 10:46
Re: Websockets call from javascript
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
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
-
- Posts: 2
- Joined: 03 Feb 2018, 10:46
Re: Websockets call from javascript
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);
}
}
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);
}
}
Return to “SFS2X HTML5 / JavaScript API”
Who is online
Users browsing this forum: No registered users and 40 guests