Raised This Month: $12 Target: $400
 3% 

HTTP:X


Post New Thread Reply   
 
Thread Tools Display Modes
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-14-2016 , 17:07   Re: HTTP:X
Reply With Quote #21

I guess you could emulate a datapack with a cellarray then, that should work.

Last edited by klippy; 09-14-2016 at 17:08.
klippy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 09-14-2016 , 17:14   Re: HTTP:X
Reply With Quote #22

Quote:
Originally Posted by Black Rose View Post
Looping through indexes in this way is really no problem at all. I guarantee you that you will never notice a difference.

However I do like the idea of passing and retrieving custom data and I will add this as a feature unless problems arise. The question becomes "how much". Infinite would be nice but that will require dynamic arrays or tries.

A good option could be to enable an integer to be passed where you could supply an array index if you wanted to which would require some more work from the user but will create more freedom without all the back-end.

I will take a look at this ASAP.
Thank you for your suggestion.
well i guess it better to pass the index directly into the handler when downloading 2 or more files btw MAX_DOWNLOAD_SLOTS 10 does that mean the plugin can't download 32 files when players connect at the same time ?
__________________
JusTGo is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 09-14-2016 , 17:22   Re: HTTP:X
Reply With Quote #23

JustGo,

PHP Code:
#include <amxmodx> 
#include <httpx> 
#include <json> 

new g_ClientTrace[33

new 
idCount;

public 
plugin_init() { 
    
register_plugin("HTTP:X Searching chunks example""2.0""[ --{-@ ]"); 


public 
client_putinserver(id

    new 
sBuffer[128], IP[24]  
    
    
get_user_ip(id,IP,charsmax(IP),1
    
    
format(sBuffer127"http://ip-api.com/json/%s"IP
    
    
g_ClientTrace[id] = HTTPX_Download(sBuffer_"Complete"); 


public 
client_disconnect(id

    
g_ClientTrace[id] = 
    idCount
--;


public 
Complete(DownloadIDError) { 
    if ( 
Error 
    { 
        
server_print("Something went wrong..."
        return; 
    } 
    
    
idCount++;
    
    new 
szName[32];
    
get_user_name(idCountszNamecharsmax(szName))
    

    
server_print("file download complete."
    
    new 
buffer[1024]; 
    
HTTPX_GetData(buffercharsmax(buffer)); 
    
    if(!
is_user_connected(idCount)) 
        return 
    
    new 
JsonHandle:jroot json_object() 
    new 
error_buffer[32
    
jroot json_loads(bufferJSON_REJECT_DUPLICATESerror_buffersizeof(error_buffer)) 
    
    if(
jroot == INVALID_JSON
    { 
        
server_print("Coudln't decode json."
        return 
    } 
    
    new 
JsonHandle:data json_object() 
    new 
country[24],city[24],isp[24
    
    
data json_object_get(jroot"country"
    if(
data == INVALID_JSON
    { 
        
server_print("Coudln't find country."
        return 
    } 
    
json_string_value(datacountrysizeof(country)) 
    
    
data json_object_get(jroot"city"
    if(
data == INVALID_JSON
    { 
        
server_print("Coudln't find city."
        return 
    } 
    
json_string_value(datacitysizeof(city)) 
    
    
data json_object_get(jroot"isp"
    if(
data == INVALID_JSON
    { 
        
server_print("Coudln't find isp."
        return 
    } 
    
json_string_value(dataispsizeof(isp)) 
    
    
destroy_json(data
    
destroy_json(jroot
    
    
server_print("name: %s | country:%s | city:%s | isp:%s",szName,country,city,isp

Freezo Begin is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 09-14-2016 , 17:41   Re: HTTP:X
Reply With Quote #24

Quote:
Originally Posted by Freezo Begin View Post
JustGo,

PHP Code:
#include <amxmodx> 
#include <httpx> 
#include <json> 

new g_ClientTrace[33

new 
idCount;

public 
plugin_init() { 
    
register_plugin("HTTP:X Searching chunks example""2.0""[ --{-@ ]"); 


public 
client_putinserver(id

    new 
sBuffer[128], IP[24]  
    
    
get_user_ip(id,IP,charsmax(IP),1
    
    
format(sBuffer127"http://ip-api.com/json/%s"IP
    
    
g_ClientTrace[id] = HTTPX_Download(sBuffer_"Complete"); 


public 
client_disconnect(id

    
g_ClientTrace[id] = 
    idCount
--;


public 
Complete(DownloadIDError) { 
    if ( 
Error 
    { 
        
server_print("Something went wrong..."
        return; 
    } 
    
    
idCount++;
    
    new 
szName[32];
    
get_user_name(idCountszNamecharsmax(szName))
    

    
server_print("file download complete."
    
    new 
buffer[1024]; 
    
HTTPX_GetData(buffercharsmax(buffer)); 
    
    if(!
is_user_connected(idCount)) 
        return 
    
    new 
JsonHandle:jroot json_object() 
    new 
error_buffer[32
    
jroot json_loads(bufferJSON_REJECT_DUPLICATESerror_buffersizeof(error_buffer)) 
    
    if(
jroot == INVALID_JSON
    { 
        
server_print("Coudln't decode json."
        return 
    } 
    
    new 
JsonHandle:data json_object() 
    new 
country[24],city[24],isp[24
    
    
data json_object_get(jroot"country"
    if(
data == INVALID_JSON
    { 
        
server_print("Coudln't find country."
        return 
    } 
    
json_string_value(datacountrysizeof(country)) 
    
    
data json_object_get(jroot"city"
    if(
data == INVALID_JSON
    { 
        
server_print("Coudln't find city."
        return 
    } 
    
json_string_value(datacitysizeof(city)) 
    
    
data json_object_get(jroot"isp"
    if(
data == INVALID_JSON
    { 
        
server_print("Coudln't find isp."
        return 
    } 
    
json_string_value(dataispsizeof(isp)) 
    
    
destroy_json(data
    
destroy_json(jroot
    
    
server_print("name: %s | country:%s | city:%s | isp:%s",szName,country,city,isp

ty for try but i think that players can disconnect before they trigger client_putinserver ? also this isn't a solution if you try to get the data in the middle of game.
__________________
JusTGo is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-14-2016 , 17:54   Re: HTTP:X
Reply With Quote #25

Quote:
Originally Posted by JusTGo View Post
well i guess it better to pass the index directly into the handler when downloading 2 or more files btw MAX_DOWNLOAD_SLOTS 10 does that mean the plugin can't download 32 files when players connect at the same time ?
It will que the files. It allows 10 simoultaneous downloads. As soon as one download is done and there are downloads left in the que they will be added automatically. Tomorrow I will test the time it takes to download 32 examples.



Edit:
It's done.
HTTPX_SetCustom(DownloadID, any:val)
any:HTTPX_GetCustom(DownloadID)

HTTP:X will update automatically, you don't need to download it manually.



I also tested the time it took to completely download a different number of files at the same time.
Don't run this yourself as I got banned doing it. Allthough I ran it using 1s delay between each run.
Code:
#include <amxmodx> #include <httpx> #define TimerStart()            tickcount() #define TimerMid(%0)            ( tickcount() - %0 ) #define TimerStop(%0)         ( %0 = tickcount() - %0 ) #define TimerDays(%0)         ( %0 / 86400000 ) #define TimerHours(%0)      ( %0 % 86400000 / 3600000 ) #define TimerMinutes(%0)        ( %0 % 3600000 / 60000 ) #define TimerSeconds(%0)        ( %0 % 60000 / 1000 ) #define TimerMilliseconds(%0)   ( %0 % 1000 ) new gNum, gCount, hTimer; public plugin_init() {     register_plugin("Time test", "1.0", "[ --{-@ ]");     set_task(10.0, "TestDownload"); } public TestDownload() {     gCount = 0;     gNum++;     new szURL[40];     hTimer = TimerStart();     for ( new i ; i < gNum ; i++ ) {         format(szURL, charsmax(szURL), "http://ip-api.com/json/%d.%d.%d.%d", random(256), random(256), random(256), random(256));         HTTPX_Download(szURL, _, "Complete");     } } public Complete(DownloadID, Error) {     if ( Error )         return;     if ( ++gCount != gNum )         return;     TimerStop(hTimer);     new szTimer[32];     TimerFormat(hTimer, szTimer, charsmax(szTimer), 2);     server_print("%-2.2d download%s: %s (%-4.4dms/download)", gNum, gNum == 1 ? " " : "s", szTimer, hTimer/gNum);     if ( gNum < 32 )         set_task(60.0, "TestDownload"); } stock TimerFormat(hTimer, output[], maxlen, mode = 1, bool:full = false) {     new len;         if ( full || TimerDays(hTimer) )         len = formatex(output, maxlen, mode == 1 ? "%02d:" : "%dd ", TimerDays(hTimer));     if ( full || ( len && mode == 1 ) || TimerHours(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%02d:" : "%dh ", TimerHours(hTimer));     if ( full || ( len && mode == 1 ) || TimerMinutes(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%02d:" : "%dm ", TimerMinutes(hTimer));             if ( full || ( len && mode == 1 ) || TimerSeconds(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%02d." : "%ds ", TimerSeconds(hTimer));     if ( full || ( len && mode == 1 ) || TimerMilliseconds(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%03d" : "%dms", TimerMilliseconds(hTimer)); }

Code:
1 download : 261ms (261ms/download)
2 downloads: 285ms (142ms/download)
3 downloads: 311ms (103ms/download)
4 downloads: 340ms (85ms/download)
5 downloads: 367ms (73ms/download)
6 downloads: 400ms (66ms/download)
7 downloads: 439ms (62ms/download)
8 downloads: 475ms (59ms/download)
9 downloads: 511ms (56ms/download)
10 downloads: 547ms (54ms/download)
11 downloads: 676ms (61ms/download)
12 downloads: 702ms (58ms/download)
13 downloads: 740ms (56ms/download)
14 downloads: 755ms (53ms/download)
15 downloads: 781ms (52ms/download)
16 downloads: 818ms (51ms/download)
At this point I was banned and the test ended.
As you can see from the data I managed to gather before getting banned the time per download decreased logarithmically.
When reaching the end of the maximum number of downloads (10) the que is activated for the 11th entry and the time per download gets a small bump but then settles down and passes the previous results.
It will probably continue to get more effective throughout. Theoretically the only bump should be at 10 downloads. After that the que will keep active at all times and shouldn't affect the time in a negative way anymore.
Without following the pattern too much, assuming it will stagnate at 50ms/download you're looking at 1.6s for 32 players.

Edit:
I ran a second test using my own HTTP server (about 2m away on a gigabit LAN) and the result was interesting.
For every download added ~10ms was added to the time. And after every tenth an extra 100ms was added. Most likely due to the que work.
This is more or less the time of the internal works of the plugin. The other factor being response time and connection speed to the server.
Code:
1  download : 209ms(~210) (209 ms/download) +~210
2  downloads: 220ms(~220) (110 ms/download) +~ 10
3  downloads: 228ms(~230) (76  ms/download) +~ 10
4  downloads: 240ms(~240) (60  ms/download) +~ 10
5  downloads: 250ms(~250) (50  ms/download) +~ 10
6  downloads: 261ms(~260) (43  ms/download) +~ 10
7  downloads: 269ms(~270) (38  ms/download) +~ 10
8  downloads: 280ms(~280) (35  ms/download) +~ 10
9  downloads: 290ms(~290) (32  ms/download) +~ 10
10 downloads: 299ms(~300) (29  ms/download) +~ 10
11 downloads: 409ms(~410) (37  ms/download) +~110
12 downloads: 418ms(~420) (34  ms/download) +~ 10
13 downloads: 429ms(~430) (33  ms/download) +~ 10
14 downloads: 440ms(~440) (31  ms/download) +~ 10
15 downloads: 449ms(~450) (29  ms/download) +~ 10
16 downloads: 459ms(~460) (28  ms/download) +~ 10
17 downloads: 469ms(~470) (27  ms/download) +~ 10
18 downloads: 478ms(~480) (26  ms/download) +~ 10
19 downloads: 488ms(~490) (25  ms/download) +~ 10
20 downloads: 499ms(~500) (24  ms/download) +~ 10
21 downloads: 609ms(~610) (29  ms/download) +~110
22 downloads: 619ms(~620) (28  ms/download) +~ 10
23 downloads: 629ms(~630) (27  ms/download) +~ 10
24 downloads: 639ms(~640) (26  ms/download) +~ 10
25 downloads: 648ms(~650) (25  ms/download) +~ 10
26 downloads: 658ms(~660) (25  ms/download) +~ 10
27 downloads: 670ms(~670) (24  ms/download) +~ 10
28 downloads: 679ms(~680) (24  ms/download) +~ 10
29 downloads: 689ms(~690) (23  ms/download) +~ 10
30 downloads: 699ms(~700) (23  ms/download) +~ 10
31 downloads: 809ms(~810) (26  ms/download) +~110
32 downloads: 818ms(~820) (25  ms/download) +~ 10
__________________

Last edited by Black Rose; 09-15-2016 at 16:04.
Black Rose is offline
krizsi123
Junior Member
Join Date: Aug 2013
Old 04-22-2018 , 15:44   Re: HTTP:X
Reply With Quote #26

Hi.

I tried to use it but I get this error:

L 04/22/2018 - 21:51:14: [AMXX] Plugin "test.amxx" failed to load: Plugin uses an unknown function (name "HTTPX_Download") - check your modules.ini.
krizsi123 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-28-2018 , 05:47   Re: HTTP:X
Reply With Quote #27

It seems like you're not running the core plugin.

Double-check that...
  • The httpx.amxx file is in the plugins folder.
  • You have a file called config/plugins.ini with a line that says "httpx.amxx" in it.
  • The plugin shows up when you write "amxx plugins" or "amx_plugins" in console.
__________________

Last edited by Black Rose; 04-28-2018 at 05:50.
Black Rose is offline
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 07-15-2019 , 05:00   Re: HTTP:X
Reply With Quote #28

Hi!
I have been using this for a long time already, but it seems that your website has gone offline and I get this message in logs:
Quote:
[httpx.amxx] [HTTP:X] Socket error: Couldn't resolve hostname. (digitaldecay.eu)
Any plans to update it or I should just disable the check for new versions?
RaZ_HU is offline
sky_pg
Member
Join Date: Apr 2012
Old 11-21-2019 , 17:21   Re: HTTP:X
Reply With Quote #29

Quote:
Originally Posted by RaZ_HU View Post
Hi!
I have been using this for a long time already, but it seems that your website has gone offline and I get this message in logs:


Any plans to update it or I should just disable the check for new versions?
same here
sky_pg is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 11-22-2019 , 07:27   Re: HTTP:X
Reply With Quote #30

i also tryed this plugin some days ago and got the same error...guys go with curl
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode