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

HTTP:X


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Technical/Development       
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-21-2016 , 12:37   HTTP:X
Reply With Quote #1

HTTP:X

This plugin is an API to download files and web content to the server and/or send commands using the HTTP protocol through other plugins.
It is not used to send files to clients. That is impossible.

This plugin will always keep itself up to date by automatically downloading the latest version whenever a new one is available.
This means that you as a developer can be relatively sure that the client has the correct version if your plugin requires possibly new functions.
This can be disabled by cvar.

You can also use this plugin to update your own plugin automatically. I suggest adding a version check first. Examples can be found below.
Remember that floats in PAWN are not 100% accurate so integers or strings should be used for checking if there is a new version available.
Also remember that for your plugin to be updated (downloaded) it has to compile without custom includes on this site. So any external functions has to be included inside the source of your plugin.
This can also be disabled by cvar.

Examples


httpx.inc


Changelog


Additional notes:
I'm always open to suggestions, feedback and criticism. Please share your thoughts.
Attached Files
File Type: sma Get Plugin or Get Source (httpx.sma - 1979 views - 42.4 KB)
File Type: inc httpx.inc (8.1 KB, 839 views)
__________________

Last edited by Black Rose; 11-19-2017 at 16:55.
Black Rose is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-21-2016 , 13:34   Re: HTTP:X
Reply With Quote #2

How i spoke

You're not human
You're a E.T
You're awesome
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Old 05-21-2016, 13:59
fysiks
This message has been deleted by fysiks. Reason: nvm
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 05-22-2016 , 05:01   Re: HTTP:X
Reply With Quote #3

Thanks. Its very useful for working with json api.
__________________
The functional way is the right way
GordonFreeman (RU) is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-22-2016 , 08:02   Re: HTTP:X
Reply With Quote #4

Didn't really look through your code thoroughly, but I noticed something. Why do you use callfunc_* natives in your auto-updater? Fake natives were made to avoid that, I believe, and it would make it simpler and easier to remember.

Also, here's something interesting you might want to take a look at: https://github.com/rsKliPPy/webserver_amxx. You could look at it as a server for the client you just wrote here, so it would allow cross-server communication with HTTP, almost like JS/AJAX. I was just too lazy past couple of months to add some finishing touches and release it. :/ Tell me what do you think about it.

Great job overall!

Last edited by klippy; 05-22-2016 at 08:19.
klippy is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-22-2016 , 12:40   Re: HTTP:X
Reply With Quote #5

I use callfunc_* because it doesn't make a plugin fail if the function doesn't exist.
That way, people can build autoupdate into their plugins but not make HTTP:X a requirement for it to run, just an option.

Honestly, I don't understand what the webserver is for.
Communication plugins are already out there with less overhead and more flexibility. This was not made to compete with them.
__________________
Black Rose is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-22-2016 , 13:44   Re: HTTP:X
Reply With Quote #6

There is set_module_filter() if the API user decides he wants it optional when using natives.
Even if you want it to stay that way, you should wrap it into a stock functions in your include file. Along the lines of:
PHP Code:
stock HTTPX_AutoupdatePlugin(const file_id[], frequency) {
    if ( 
callfunc_begin("AutoupdatePlugin""httpx.amxx") == ) {
        
callfunc_push_int(get_plugin(-1));
        
callfunc_push_str(file_idfalse);
        
callfunc_push_int(frequency);
        
callfunc_end();
    }

and callfunc might be also bad for a reason that it relies on plugin name, that is "httpx.amxx". That's pretty hardcoded in my opinion.


I know this may be going a bit offtopic, but the webserver is basically a module for hosting a HTTP server on top of a HL server. It's a GoldSrc/HL counterpart of Asherkin's HTTP server. It lets one program dynamic web pages with Pawn, just like you would do with PHP for example. Just a fun project and I brought that up as your plugin revolves around HTTP.
Cross-server communication was just an example what those two could do if they got their powers combined.

Last edited by klippy; 05-22-2016 at 13:45.
klippy is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-22-2016 , 18:08   Re: HTTP:X
Reply With Quote #7

If a plugin was using the include there would be no point of autoupdating since it wouldn't pass the compiler. This is done intentionally.
I don't see how set_module_filter() would help in this case. I have never used that function and I'm having a hard time understanding what it actually does. If you can show me what your thoughts were I would appreciate it.

The hardcoded part I could edit easily. I'll do that tomorrow. Done
Thank you for your feedback.

I'm not very experienced in C(#/++). But as far as I can tell your HTTP server looks professional.
__________________

Last edited by Black Rose; 05-23-2016 at 13:09.
Black Rose is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-22-2016 , 19:03   Re: HTTP:X
Reply With Quote #8

Quote:
Originally Posted by Black Rose View Post
If a plugin was using the include there would be no point of autoupdating since it wouldn't pass the compiler. This is done intentionally.
I don't see how set_module_filter() would help in this case. I have never used that function and I'm having a hard time understanding what it actually does. If you can show me what your thoughts were I would appreciate it.
Oh, I totally misunderstood how the plugin updater works. I just saw that it actually downloads files from the web compiler, that wasn't obvious at first. Now I see why you used callfunc instead of creating a native, that explains it.
But here's the question then - what if a plugin includes a non-standard include file? Just like your own? That could be solved by copying include file's contents onto the top of the code, but that's not really the solution.

Quote:
Originally Posted by Black Rose View Post
Thank you for your feedback.
Anytime. I really like this plugin/API and I am happy to help at improving it.
klippy is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-23-2016 , 13:24   Re: HTTP:X
Reply With Quote #9

It depends on the include. Some things are just stupid to move into an include. ColorChat is a great example. One small, simple function that comes in too many different versions.
If people copied the code instead they would compile fine online and it wouldn't be so hard to find the right version of colorchat.

It got me thinking and I'm gonna create an add-on that will update plugins instead. I think that will be easier for everyone. But that still won't work with custom includes.

This can be solved by using another compiler with the proper includes but I will not use anything else than downloads from AM. Mainly because malicious code is rare and will be removed but also for the sake of the GPL being enforced here.
__________________

Last edited by Black Rose; 05-23-2016 at 13:24.
Black Rose is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 05-26-2016 , 15:19   Re: HTTP:X
Reply With Quote #10

Why don't you make a Multi-threaded solution too instead of entity thinks ? ThreadedSocks
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 05-31-2016 at 04:18.
Shooting King 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 07:44.


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