Jump to content
minipopov

[Release] oo_Webservice class using OOP

Recommended Posts

Hello,

 

I just release one class which use RscHTML to interact with API REST throw GET. 
You could check my code on: https://github.com/minipopov/WebService

Don't forget to add ip from your webservice to in allowedHTMLLoadURIs (inside CfgCommands) like this exemple https://community.bistudio.com/wiki/CfgCommands
Don't forget to add oop.h to your mission : https://github.com/code34/oop.h

How to use instantiate class?

private _webservice = ["new", "http://localhost:8080/"] call oo_WebService;

Then put some args :

private _arr = [
	["action", "update"],
	["table", "users"],
	["id", getPlayerUID]
];
["putParam", _arr] call _webservice;

And finally call it:

private _index = "call" _webservice;

It return index of request. You could get request state from index by getStatus

private _data = ["getStatus", _index] call _webservice;

Which is an array that contain in 0, the status of request "waiting"/"complete"/"timeout"(if request goes to timeout ofc..)/"undefine" if you give bad index. And at 1 the diag_ticktime when request was executed.

So, as you could see there is timeout for request that you could set like this

["setTimeOut", 10] call _webservice; //time in second

Old request are delete, you could set default time that script keep in memory request

["setKeepInMemory", 500] call _webservice; //Keep all request 500s after there exec

Sadly, i didn't find any way to get the output of RscHTML... If anyone know the way to do it.. Hope it could be done to do something a bit more complex like get something in database or something like that..

 

Im so sorry for my fucking english.. ^^

 

Here:Exemple of usage:

 

  • Like 1

Share this post


Link to post
Share on other sites

What kind of return do you get with this? Do you get the text of the page you visit?

Share this post


Link to post
Share on other sites

Arma didn't inplement any function to get text on RscHTML, at least i didn't find any way to do this. Only return that you could have is true when load is success/false when not.

Share this post


Link to post
Share on other sites
4 hours ago, minipopov said:

Arma didn't inplement any function to get text on RscHTML, at least i didn't find any way to do this. Only return that you could have is true when load is success/false when not.

Well what I was going to do it make a sort of raw Rcon input from arma 3 and have it send rcons via loadhtml and get a return. What I think I'll do instead is do the same thing but in the php file send the return to a database table and just pull that through arma.

Share this post


Link to post
Share on other sites

Ok, if you arrive to get a return from request, that would be great :)

Share this post


Link to post
Share on other sites
9 hours ago, minipopov said:

Ok, if you arrive to get a return from request, that would be great :)

Well like I was saying, I'm just going to get a return though a mysql database. I'll send a command to a php file, then it'll send its output to a php file and then I'll have a delay set in the script so then it'll check for a return after the delay which should now be in there.

Share this post


Link to post
Share on other sites

Yeah you could do this. It s sad that we couldn't just read the return by ctrlText.... (arma plz, do it)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×