So here it is, v2.0 of url_fetch extension. I have to admit I am not entirely happy with v1.0, mostly because it needs 3rd party libraries. cURL library is fine but it also needs another 3rd party library to work, which is OpenSSL. I never managed to make v1.0 run on my WinXP box because OpenSSL just didn’t like it, and this was bothering me.
So I decided to abandon cURL all together and try something more simple. Considering the task at hand, i.e. simply to connect to URL and exchange data, using cURL is pretty much an overkill. And since you can only use extensions on Windows Arma server, why not look at some Windows API for solution?
In this extension I used Internet Explorer API to get the URL content, save it into temporary Internet cache file, read contents into a string and delete the cache file. Because the extension is asynchronous and launches a new thread to make the Internet call, this method of getting URL content works just fine.
The benefits are small size, single .dll, which also runs on WinXP. The MSIE API resolves URLs just like a browser would, so if there is a redirect in place it will follow it and deliver only the final landing page content. I haven’t added any timeout cut off. If a server not responding, extension might wait as long as an hour for the response. You will know if there is a problem with the server, because next call to extension will return “BUSY” instead of “OK”.
As you can see from the video, the procedure of working with v2.0 extension is pretty much the same as with the v1.0. You submit request and check later for the result. If there is an error, you can get an idea about what went wrong. And just like with v1.0, the large output will be truncated to the default output size, which you can check with debug_console v3.0 if you want.
What could this extension be used for? You can update your website with your server status in real time. You can add a layer of real world into your game dynamically by querying outside resources during the game. What you should not do with this, is use it as a replacement for database operation to store and retrieve player details. You need socket based connection for this and not file based operation like this.
If you had v1.0 installed you can now delete all the files that came with it. This single .dll is all you need now and should also be backwards compatible. It should work with both Arma 2 and Arma 3.
You might need to download and install Visual C++ Redistributable for Visual Studio 2013 from Microsoft website to make sure the extension works without a hitch.
Unzip and drop url_fetch.dll into the root folder on your Arma dedicated Windows server. To simply test if .dll is operational, add this in init.sqf:
Join the server and check server .rpt file. If you see something along the lines of: KK’s ArmA 3 url_fetch v2.0 http://killzonekid.com, the .dll works fine on your system.
Make file url_fetch.sqf and drop in your mission root folder. The file should contain the following code:
This is more or less the same code I used in v1.0. You can execute the code in 2 different ways. You can either compile the code into a function and then spawn it like this:
Or execute the code directly with execVM command like this:
EDIT: The url_fetch dll extension has now been updated to v2.1 with increased reliability.
EDIT2: url_fetch with callback tutorial is now available