Raised This Month: $108 Target: $400
 27% 

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: Upplands Väsby, Sweden
Old 05-21-2016 , 13: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 - 125 views - 42.4 KB)
File Type: inc httpx.inc (8.1 KB, 63 views)

Last edited by Black Rose; 11-19-2017 at 17:55.
Black Rose is offline
Send a message via Skype™ to Black Rose
EFFx
Veteran Member
Join Date: Feb 2016
Location: Brazil, SP
Old 05-21-2016 , 14:34   Re: HTTP:X
Reply With Quote #2

How i spoke

You're not human
You're a E.T
You're awesome
__________________
EFFx is offline
Send a message via Skype™ to EFFx
Old 05-21-2016, 14: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 , 06: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
Send a message via ICQ to GordonFreeman (RU)
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-22-2016 , 09: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 09:19.
KliPPy is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 05-22-2016 , 13: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
Send a message via Skype™ to Black Rose
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-22-2016 , 14: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 14:45.
KliPPy is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 05-22-2016 , 19: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 14:09.
Black Rose is offline
Send a message via Skype™ to Black Rose
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-22-2016 , 20: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: Upplands Väsby, Sweden
Old 05-23-2016 , 14: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 14:24.
Black Rose is offline
Send a message via Skype™ to Black Rose
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 05-26-2016 , 16: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

Last edited by Shooting King; 05-31-2016 at 05: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 06:21.


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