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

Klippy's Webserver


Post New Thread Reply   
 
Thread Tools Display Modes
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-05-2016 , 10:50   Re: Klippy's Webserver
Reply With Quote #21

Does it not crash for you even when using the last plugin I posted? It crashes for me on a regular and listen servers within a few seconds.
PartialCloning is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-10-2016 , 07:08   Re: Klippy's Webserver
Reply With Quote #22

750 requests while continuously holding CTRL + R, both when just rejecting with MHD_NO or sending motd.txt, no problems at all. Can't reproduce.

By the way, I'm currently redesigning the whole API. The plan is to make it look more like Node.js Express' API, which I quite like. It may be overkill though, who knows. This is what I have as of yet:
PHP Code:
#define WS. WS__

const WS_IP_MAXLENGTH 16;

enum WSRequestMethod (<<= 1)
{
    
WSRM_Get 1,
    
WSRM_Post,
    
WSRM_Put,
    
WSRM_Head
};

enum WSLocalType
{
    
WSVT_Int 0,
    
WSVT_Float,
    
WSVT_String,
    
WSVT_Boolean
};

// Router object
native WSRouter:WS.CreateRouter();
public const 
WSRouter:WS.Application;

// Request handling / Middleware
native WSCallback:WS.CreateCallback(const callback[]);
native WS.Use(WSRouter:router, {WSRouter,WSCallback}:use, const path[] = "/");
native WS.HandleRequest(WSRouter:routerWSRequestMethod:requestMethodWSCallback:callback, const path[]);
native WS.Next(WSNext:next);

//Every Callback looks like
//public Callback(WSRequest:request, WSResponse:response, WSNext:next);

// Request object
native WS.RequestGetIp(WSRequest:requestip[WS_IP_MAXLENGTH]);
native WS.RequestGetBasePath(WSRequest:requestbasePath[], maxLength);
native WS.RequestSetCookie(WSRequest:request, const cookie[], const value[]);
native WS.RequestGetCookie(WSRequest:request, const cookie[], value[], maxLength);

// Response object
native WS.ResponseSetLocal(WSResponse:response, const variable[], WSLocalType:typeany:...);
native bool:WS.ResponseGetLocal(WSResponse:response, const variable[], WSLocalType:typeany:...);
native WS.ResponseEnd(WSResponse:response);
native WS.ResponseRedirect(WSResponse:response, const path[]);
native WS.ResponseSendBinary(WSResponse:response, const body[]);
native WS.ResponseSendString(WSResponse:response, const body[]);
native WS.ResponseSendFile(WSResponse:response, const filePath[]);
native WS.ResponseSetStatus(WSResponse:responsestatusCode);
native WS.ResponseSetHeader(WSResponse:response, const header[], const value[]);
native WS.ResponseGetHeader(WSResponse:response, const header[], value[], maxLength); 
Some things may change in the meantime, but that's pretty much it. If you knew how Express works it would be much easier for you to understand the new API, because I haven't documented it yet.
The callback system may seem confusing because every native that accepts a callback accepts an object instead of a function name. It's made that way so plugins can share callbacks using natives or xvars, so your plugin can provide a middleware for someone else's for example.
It should also allow requests not to be responded to immediately like with the previous API, meaning that you can for example grab something from MySQL using threaded queries then respond to a request.

Anyway, the whole module will undergo a rewrite.

Last edited by klippy; 12-10-2016 at 07:27.
klippy is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-16-2016 , 00:56   Re: Klippy's Webserver
Reply With Quote #23

That's odd, it crashes for me almost instantly under windows.

I look forward to the rewrite. If you're taking suggestions there is a sourcemod extension that's similar to your module: https://forums.alliedmods.net/showthread.php?t=270962
PartialCloning is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-16-2016 , 20:34   Re: Klippy's Webserver
Reply With Quote #24

Quote:
Originally Posted by PartialCloning View Post
If you're taking suggestions there is a sourcemod extension that's similar to your module: https://forums.alliedmods.net/showthread.php?t=270962
You will notice that the mine and Asherkin's APIs are pretty much the same. That's because I took inspiration from it in the first place - I even used the same HTTP library.
klippy is offline
Hectik17
AlliedModders Donor
Join Date: Oct 2005
Old 02-05-2017 , 16:32   Re: Klippy's Webserver
Reply With Quote #25

Could this implement a pug rank system one te wins 15 rounds then the payers on that team recive 1 point towards there name. So when players are puging they have somthing to play for braging rights.
Hectik17 is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 03-20-2017 , 19:32   Re: Klippy's Webserver
Reply With Quote #26

Quote:
Originally Posted by KliPPy View Post
---
Is that attached module the latest version? I noticed there was a commit in github 2 weeks after your post. Do you have any plans to try to get this module included within 1.8.3? It opens up a whole new dimension when it comes to amx scripting, not to mention there is a pull request for a JSON module where as webserver is much more of a game changer and if new modules are to be added it should be prioritized along with (a fixed) Okapi.
PartialCloning is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-21-2017 , 10:26   Re: Klippy's Webserver
Reply With Quote #27

Quote:
Originally Posted by PartialCloning View Post
Is that attached module the latest version? I noticed there was a commit in github 2 weeks after your post.
Not sure, I remember I only added AMBuild to the project and that's it, no internal changes I think.

Quote:
Do you have any plans to try to get this module included within 1.8.3?
Nope. I don't think it needs to be included in AMXX anyway.

Quote:
It opens up a whole new dimension when it comes to amx scripting
Maybe, who knows. I don't have many ideas, but I guess other people do.


I haven't really done anything on this yet as I'm doing other stuff, but I've been thinking about it from time to time. Still thinking what HTTP server library to use, internal workings (as some stuff will be multithreaded for performance) and the API itself. Also, one of the priorities is a HTML template engine, somehow. But also waiting for that JSON PR to be merged I guess.

Last edited by klippy; 03-21-2017 at 10:27.
klippy is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 04-17-2017 , 19:26   Re: Klippy's Webserver
Reply With Quote #28

Quote:
Originally Posted by PartialCloning View Post
The server still crashes a lot randomly while spamming refresh. Even if I have nothing running in the call back. It's as if the spamming slows down the server to the point where other modules malfunction (specifically on heavy forwards so I used server_frame to test it) causing the server to crash.
After many more tests I think the cause is an overflow somewhere?

Code:
#include <amxmodx> #include <webserver> new WSResponse:gBasicMOTD; public plugin_init() {     WS_RegisterRequestCallback("home", "OnWebServerHome");     WS_RegisterRequestCallback("motd", "OnWebServerHome");     gBasicMOTD = WS_CreateStringResponse("<!DOCTYPE HTML><html><head><meta charset='UTF-8'><title>Cstrike MOTD</title><style type='text/css'>body{background:#000;margin:8px;color:#FFB000;font:normal 16px/20px Verdana, Tahoma, sans-serif;}a{color:#FFF;text-decoration:underline;}a:hover{color: #EEE;text-decoration: none;}</style></head><body>You are playing Counter-Strike v1.6<br>Visit the official CS web site @<br>www.counter-strike.net<br><a href='http://www.counter-strike.net'>Visit Counter-Strike.net</a></body></html>");     WS_AddHeader(gBasicMOTD, WSH_ContentType, "text/html"); } public OnWebServerHome(WSConnection:Connection, const Method[], const URL[]) {     return WS_QueueResponse(Connection, WS_StatusCode_OK, gBasicMOTD); } public plugin_end() {     WS_DestroyResponse(gBasicMOTD); }

Expected Behavior: Default CS MOTD.

Actual Behavior: Displays random information at the beginning of the MOTD. Random information including timeleft and plugin names. Example: "19:54menu.amxxue%....etc" where 19:54 is the timeleft and it changes to whatever the timeleft is when I refresh the page, and menu.amxx is one of the default amx menu plugins. It also displays random cvars names and amx messages "This server is using AMX Mod X".

Quote:
19:56menu.amxxue% -- This server is using AMX Mod XCstrike MOTDYou are playing Counter-Strike v1.6
Visit the official CS web site @
www.counter-strike.net
Visit Counter-Strike.net
PartialCloning is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 05-16-2017 , 08:29   Re: Klippy's Webserver
Reply With Quote #29

The bug occurs even when running NOTHING but the test plugin, no other plugin running including default amxmodx plugins.

Quote:
Content-TypeL>You are playing Counter-Strike v1.6
Visit the official CS web site @
www.counter-strike.net
Visit Counter-Strike.net
If "WS_AddHeader(gBasicMOTD, WSH_ContentType, "text/html");" is removed the bug does not occur, and it does not print "Content-TypeL>".
PartialCloning is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-16-2017 , 10:12   Re: Klippy's Webserver
Reply With Quote #30

Maybe you should currently give up on it. As you know, I've never released the module (apart from having it on GH) because it was never fully finished.

Still no plans on when I'm going to do a rewrite. The more I work on projects with other libraries and frameworks out there, the more ideas I have for this thing.
klippy 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 01:45.


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