AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   HTTP:X (https://forums.alliedmods.net/showthread.php?t=282949)

Black Rose 05-26-2016 16:07

Re: HTTP:X
 
If I would include a module I want the whole thing to be a module instead.
But it's never too late. I will see what I can do with it when I get the time.

Shooting King 05-27-2016 12:44

Re: HTTP:X
 
It would be just a waste of time for you to code Multi threaded sockets again, + Httpx would be a specific module, and ThreadedSocks will get added into Amxmodx eventually, so since this is a new plugin, i recommend you to even support Threaded mode.

Black Rose 05-27-2016 16:18

Re: HTTP:X
 
What will be added is not interesting. 1.8.3 is not really being released anytime soon. You also have to concider the adaptation. To support all servers I'm aiming for 1.8.2 compatibility. That is still the last "stable" release.
But I've already said I will take a look at it.

Shooting King 05-28-2016 15:50

Re: HTTP:X
 
lmao xDD

Black Rose 05-29-2016 06:24

Re: HTTP:X
 
Quote:

Originally Posted by Shooting King (Post 2422224)
Why don't you make a Multi-threaded solution too instead of entity thinks ? MultiThreadedSocks

Okay. I finally got time to take a look at it. I came to a halt at a point where I realize there's no way of dynamically changing the size of the packets to receive which is a killer for me.
I use 1B when getting the header and scanning for chunk sizes. Other than that I use 64KB. If you want threaded sockets to be included, you have to change this.

Shooting King 05-29-2016 09:55

Re: HTTP:X
 
socket_recv_t( const iThreadHandle, const CallBackHandler[], const iRecvDataLen ); ? iRecvDataLen ?

How could you achieve "dynamically changing size" with default sockets ? Could you give me an example to understand your problem better and if possible references in your code ? I guess its better to discuss this issue in Module's thread ?

JusTGo 09-14-2016 09:16

Re: HTTP:X
 
i want to download a file for specific player is there is a way to have played index added to complete handler for now i m looping through all players to find the related player file:
PHP Code:

#include <amxmodx>
#include <httpx>
#include <json>

new g_ClientTrace[33]

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] = 0
}

public 
Complete(DownloadIDError) {
    if ( 
Error )
    {
        
server_print("Something went wrong...")
        return;
    }
    
    
server_print("file download complete.")
    
    new 
buffer[1024];
    
HTTPX_GetData(buffercharsmax(buffer));
    
    
server_print("Recived Data:%s",buffer)
    
    new 
id GetTracedClient(DownloadID)
    
    if(!
is_user_connected(id))
        return
    
    new 
szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
    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)
}

GetTracedClient(DownloadID)
{
    new 
iPlayers32 ], iNumiTracedClient=0;
    
get_playersiPlayersiNum"ch" );
    for( 
0iNumi++ )
    {
        if(
g_ClientTrace[i] == DownloadID)
        {
            
TracedClient=g_ClientTrace[i]
            break
        }
    }
    
    return 
TracedClient



Black Rose 09-14-2016 15:36

Re: HTTP:X
 
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.

klippy 09-14-2016 16:16

Re: HTTP:X
 
If you don't mind making 1.8.3 a requirement, you could use DataPacks, they were made exactly for that.

Black Rose 09-14-2016 17:02

Re: HTTP:X
 
I do mind. I'm not developing for unofficial releases. Especially if it doesn't update automatically.


All times are GMT -4. The time now is 02:54.

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