logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Idea for nwnx_plugin - _GET / _POST

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed May 27, 2009 15:57    Post subject: Idea for nwnx_plugin - _GET / _POST Reply with quote

Would it be possible, (eg - can somone do this for me)

for someone to make a plugin that is able to do http post requests to websites?


Eg - Imagine this, in one of the most basic scenarios I can think of.

1. Player Logs in,
2. plugin accesses a php file on the web (just loads it up as if via browser)
3. Server Admin gets an e-mail alerting them to the new player.


I have made a script that does this, however, it was always working on the basis of a cronjob, being required to run every 5-10 minutes.


So, that means, it could be 10 minutes before an e-mail is sent if done via cronjob.

However, if nwnx itself, were to trigger the php file, and not via cron, it could in theory do instant requests to php files, without the need of cronjobs.




If this plugin were made, it would give the ability to do http get requests, to post data into a web script.


Eg you could specify in the nwn script what URL to access, something like

string sURL = "http://www.someURL.com";

This would be a basic use, however, more advanced uses, for posting data to the web, or somewhere else would be done via

string sURL = "http://www.someURL.com?CDKEY="+GetPCPlayerCDKEY(oPC)+"?charactername="+GetName(oPC);

This could result in a URL string being constructed like

"http://www.someURL.com?CDKEY=QULDKYNS?charactername=Sandy Brum"

(I think most browsers turn " " blank spaces into %20 by default, but from a plugin point of view, this is something that might need to be scripted or coded into the dll itself.



Can anyone else think of any reasons why this might be useful.



I for one would find it EXCEPTIONALLY useful for Forum integration.
MYSql polling is good an all, however, it relys too much on batch jobs, and cronjobs, which can be resource intensive, and could even fail if the cronjob itself gets into lengthy loops.

Direct HTTP get requests though, triggered by NWNx itself, would be alot simpler, it could even be programmed to receive http post data too as post back's.


Eg - Post data to site, receive a response, response is fed into NWNx, and then into NWN, and then handled by scripting.
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Wed May 27, 2009 16:04    Post subject: Reply with quote

Synchronous HTTP requests will hang your server until the HTTP session is over.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed May 27, 2009 16:14    Post subject: Synchronous HTTP requests Reply with quote

Synchronous HTTP requests?

I know there is Synchronous, and ASynchronous.

Is either of these able to perform requests without hanging while the HTTP session is in progress?


Does MYSql SQLFetch cause hanging?


In theory, its much the same as an http request,
post/access website,
wait for response.

in mySQL
post/select from database
receive response.

since the SQLFETCH always returns either SQL_SUCCESS or SQL_FAIL, im guessing there is a timeout at which it decides if the query has failed.

Is there any reason why a timeout could not be put into the http plugin.


Im not proposing that the plugin is used to download, or access content rich websites.

Ideally, it would be blank php sites, designed to accept variables via
<?php
$var1 = $_GET['var1'];
?>

and then use $var1 in whatever function is programmed into the php.

Eg - E-mail functions,

Imagine ingame purchases, that could actually e-mail a receipt of purchase to the buyer. Using conversations etc, the player could input their e-mail address into their characters account.


I guess I can admit, that the need for something like this is 'remote' but I thought it might be an interesting challenge, and would give some new possibilities to NWN servers.
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Wed May 27, 2009 16:31    Post subject: Reply with quote

The easiest way would be to use NWNX Ruby plugin and write the HTTP request code in Ruby (with threading for async requeses), then just call it from NWScript.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed May 27, 2009 16:41    Post subject: NWNX Ruby plugin Reply with quote

Where can I get this NWNX Ruby plugin?

Does it work on Windows?
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Wed May 27, 2009 19:04    Post subject: Reply with quote

Ah, Windows, right... Unfortunately, there is no Windows port of NWNX Ruby.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Mon Jun 01, 2009 9:27    Post subject: Reply with quote

Baal you might be able to create a new thread and return so your NWServer keeps going. Have the new thread open an itnernet connection to whatever server on port 80 and send the desired HTTP protocol string you have in mind.

A secondary choice is to put your requests in the database as a string or somesuch. Then, write a stand-alone program (very quickly done in .NET) to poll the database at intervals. Dequeue and perform the desired operation.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group