dpj

Http Plugin

Recommended Posts

Http GSC Plugin

This plugin allows you to do http requests within your gsc scripts. It's up to your creativity what to do with it :)

callback(content) // callback function receiving the request content as string
{
   iprintln("out:" + content); // print the result
}

...

httpget("127.0.0.1/test.php", ::callback);

Fyi:

* To use the plugin a bleeding edge server version is needed .. as linked below

* Completely untested on Windows

download: https://github.com/callofduty4x/cod4x_plugin_http/releases/download/v0.1.0/libcod4x_http_plugin.so

compatible server version: https://github.com/D4edalus/CoD4x_Server/releases/download/v16.1.1/cod4x18_dedrun

source: https://github.com/callofduty4x/cod4x_plugin_http

PS: let us know what you use it for :)

Share this post


Link to post
Share on other sites

He tells you in his post... Load the plugin like you do with any other plugin, and implement the callback method in one of your gsc scripts. If you don't know how to script, then you have no need for this anyway.

Share this post


Link to post
Share on other sites

Hi, D4edalus, Its not working.. Can you explain how it works. If you give an example of its use, it will be helpful ..The plugin Requires d-apt repositories in the system inorder to load the plugin sucessfully..I made a simple test.php   & tested the code, but it returns or prints nothing...

PHP<?phpecho  'Welcome to Test Page 
Im C-BIN  ';  ?>GSCinit(){    wait 20;    httpget("139.59.15.22/test.php",::callback);}callback(content) // callback function receiving the request content as string{    iprintln("^1Test out:^7" + content); // print the result}

In the server console it resolves the ip successfully and prints this 

fiber update 0

Is this plugin for retreiving contents from websites ?

Share this post


Link to post
Share on other sites
Hi' date=' D4edalus, Its not working.. Can you explain how it works. If you give an example of its use, it will be helpful ..The plugin Requires d-apt repositories in the system inorder to load the plugin sucessfully..I made a simple test.php   & tested the code, but it returns or prints nothing...
PHP<?phpecho  'Welcome to Test Page 
Im C-BIN  ';  ?>GSCinit(){    wait 20;    httpget("139.59.15.22/test.php",::callback);}callback(content) // callback function receiving the request content as string{    iprintln("^1Test out:^7" + content); // print the result}

In the server console it resolves the ip successfully and prints this 

fiber update 0

Is this plugin for retreiving contents from websites ?[/quote']yes, it is for retrieving contents from a http server. your example looks correct to me :)sorry i forgot to mention this dependency. it is the standard library / runtime library for the d programming language. libphobos2.so.0.71 as you said it can be obtained from the d-apt: http://d-apt.sourceforge.net/manually downloading from here should work too: http://downloads.dlang.org/releases/2016/i also included the dependency in the github release nowversion 0.2.0 fixes some bugs and has some simple json support ( wich is completely undocumented yet ;) ) https://github.com/callofduty4x/cod4x_plugin_http/releases/tag/v0.2.0fyi: the examples i tried so far used quite the same php code as you have. hosted on apache2 and so far i have only tested it with 127.0.0.1/ ... it should however work with different hosts too :)thx for trying, keep me posted if you are successful.PS: i'm going to include an error callback and debug mode in the next version (v0.3.0) to prevent such unreported errors

  • Like 1

Share this post


Link to post
Share on other sites

Great Job Man...

I tested v0.2.0 .. It worked with localhost (127.0.0.1) but it failed to retrieve contents from a public ip or domain..

That json function is very helpful... It can be used to identify exact geolocation & isp details of players using api :) .. For eg: ip-api.com/json/127.0.0.1

Thanks

Share this post


Link to post
Share on other sites

Great Job Man...

I tested v0.2.0  .. It worked with localhost (127.0.0.1) but it failed to retrieve contents from a public ip or domain..

That json function is very helpful... It can be used to identify exact geolocation & isp details of players using api  :) .. For eg:  ip-api.com/json/127.0.0.1

Thanks

thx for trying, i'm glad if you find it helpful :)

i experience the same bug .. will fix it soon

Share this post


Link to post
Share on other sites

Great Job Man...

I tested v0.2.0  .. It worked with localhost (127.0.0.1) but it failed to retrieve contents from a public ip or domain..

That json function is very helpful... It can be used to identify exact geolocation & isp details of players using api  :) .. For eg:  ip-api.com/json/127.0.0.1

Thanks

thx for trying, i'm glad if you find it helpful :)

i experience the same bug .. will fix it soon

There is one more thing I have experienced, I experienced a hitch warning issue when the http function executed...

I dont know if it was due to low specification of my test server...

It hitched for about 800-1200 millisecond.. Please check that too :)

It always happens when the function is executed for the first time after a map is loaded, no hitch warning after that..

Share this post


Link to post
Share on other sites

accidentally i was using a blocking instead of a non-blocking function, i guess that is the problem :) will fix it once i have time again

Share this post


Link to post
Share on other sites

Hi All, 

Try this Server Info  Script .. Might be useful for server admins to know the live status of other servers from within the server  :P .. It uses http plugin to get details of servers

Requires

cod4x http plugin & its dependancies

cod4x server https://github.com/D4edalus/CoD4x_Server/releases/download/v16.1.1/cod4x18_dedrun

Webserver in the local system (same system)

[i didnt tested it on a crowdy server, but it worked properly when I checked :) ]

Works with b3 (using customcommands plugin)(didnt tested)

Command usage:

$getinfo

More Details and instructions inside the zip file

http://smvhost.in/download/?file=smvserverinfo.zip

I made the same script that works without http plugin, which uses b3 plugin to get the contents of http. But It was not that responsive like cod4x http plugin & it was more laggy ... :P

Thanks for making http plugin

Share this post


Link to post
Share on other sites

I was trying to use this plugin in _globallogic.gsx, but the problem seems to be that the server loads plugins after parsing _globallogic.gsx. So, I get a unknown function on all of the supported functions in the plugin.

Any ideas what I should be doing?

Share this post


Link to post
Share on other sites

that doesn't sound possible to me

did you check if the plugin was loaded successfully? type "plugins" in the servers commandline

Share this post


Link to post
Share on other sites

I load the plugin through the cfg using

loadplugin libcod4x_http_plugin

I get the following error: (and the server crashes)

Error: unknown function: (file 'maps/mp/gametypes/_welcome_geo.gsc', line 38)

jsonreleaseobject(handle);

If I comment the thread for _welcome_geo in _globallogic, then if I type plugins, I can see that it is loaded.

So, then I uncomment and do a map_rotate and now _welcome_geo works.

I hope I have explained myself better now.

Share this post


Link to post
Share on other sites

The order of your commandline is important.

+set commands always come first. But other commands have their order. +map_rotate + exec server.cfg

Here the map and scripts will be loaded before server.cfg is executed.

+exec server.cfg +map_rotate

Is what you want.

Share this post


Link to post
Share on other sites

async requests are fixed

requests to other hosts than localhost work

latest builds from repositories for server and plugin are needed (no prebuilt binaries available yet)

Share this post


Link to post
Share on other sites

Http GSC Plugin

This plugin allows you to do http requests within your gsc scripts. It's up to your creativity what to do with it :)

callback(content) // callback function receiving the request content as string
{
   iprintln("out:" + content); // print the result
}

...

httpget("127.0.0.1/test.php", ::callback);

Fyi:

* To use the plugin a bleeding edge server version is needed .. as linked below

* Completely untested on Windows

download: https://github.com/callofduty4x/cod4x_plugin_http/releases/download/v0.1.0/libcod4x_http_plugin.so

compatible server version: https://github.com/D4edalus/CoD4x_Server/releases/download/v16.1.1/cod4x18_dedrun

source: https://github.com/callofduty4x/cod4x_plugin_http

PS: let us know what you use it for :)

hello deadalus

hello all

tell me what give this script

we realy need this script

thx for info

Share this post


Link to post
Share on other sites

READ, first page:

* Completely untested on Windows

yes it works on linux

Share this post


Link to post
Share on other sites

Problem. I treid it out. And still getting on loading the plugin:

Error: Sys_LoadLibrary error: libphobos2.so.0.71: cannot open shared object file: No such file or directory

Error: Failed to load the plugin /root/.callofduty4/plugin.libcod4x_http_plugin.tmp!

(Do not worry, the user isn't root)

Share this post


Link to post
Share on other sites

Problem. I treid it out. And still getting on loading the plugin:

Error: Sys_LoadLibrary error: libphobos2.so.0.71: cannot open shared object file: No such file or directory

Error: Failed to load the plugin /root/.callofduty4/plugin.libcod4x_http_plugin.tmp!

(Do not worry, the user isn't root)

clearly tells you to install the dependency

already mentioned here, read full threads folks :P https://cod4x.me/forum/thread-546-post-1830.html#pid1830

Share this post


Link to post
Share on other sites

plugin is ready for use

see readme for usage examples:

https://github.com/callofduty4x/cod4x_plugin_http

compiled plugin for linux (check previous posts for dependencies)

https://mega.nz/#!zw4FQC6J!cCQaBCza-Q1UgtSD5lhLhmDnRrmlJ9bk1llvEBgVHzQ

changes in short:

+ no more lags

+ json support

+ http post support

use with server version https://github.com/callofduty4x/CoD4x_Server/commit/7e3915f20722653908d3f4c9a9191190aa6cc1f1 or newer

Share this post


Link to post
Share on other sites

how to solve this error ?

Error: Sys_LoadLibrary error: libphobos2.so.0.71: cannot open shared object file: No such file or directory

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now