[Review] RGSS Web Kit 1.1

RGSS Web Kit
Version: 1.1
By: Gustavo Bicalho


Introduction

The RGSS Web Kit (RWK) was designed to allow simple HTTP access through RGSS. I wanted to download resources from the web, so that's what it does: download resources from the web. However, this isn't a script for people who don't know RGSS, at least some basic stuff. There's no ready-to-use "Scene_ResourceDownloader" or something like that. RWK gives you a way to get online, but it's completely up to you to make it useful.

What you can do with RWK: download resources, send Post data to a server and read the response, send requests with special headers and check the headers of the response.

You can use this to create an Online Ranking, or some kind of chat or bulletin board in your game, or to check and download updates. Like the whole game making thing, it's all up to your creativity.

Remember: this is a HTTP library, not a browser. It won't do everything for you. If you want to access some service that needs cookies, you will have to emulate those cookies by yourself and deal with the HTTP headers. The same applies to everything else beyond the normal "Get" and "Post like a web form". RWK gives you only the basic stuff.

The Demo

RWK Version 1.1 Demo has an interesting system to show the Kit's power: GusForum, an in-game forum system. It uses AWorks Input scripts for user input, REXML for XML processing (in external files) and RWK to connect to a web server and, using simple PHP scripts (that you can download below to install in your own web server), allow users to create threads and send messages that can be seen by other people through the internet.
You are free to use and modify the GusForum scripts, just remember to credit me ;)
You can download the Demo below.

Download

Demo: http://www.gust.projetorpgmaker.com/RWK_1_1/RWK%201_1.rar
RWK Scripts in txt files: http://www.gust.projetorpgmaker.com/RWK_1_1/RWK%201_1_txt.rar
AsyncHTTP.dll Source Code: http://www.gust.projetorpgmaker.com/RWK_1_1/AsyncHTTP.src.rar
GusForum Server Scripts: http://www.gust.projetorpgmaker.com/RWK_1_1/GusForum_Server.rar

Instructions

Download the Demo and copy the scripts of the section named RGSS Web Kit (the Documentation is not necessary) and the AsyncHTTP.dll to your project. The SDK is not needed.
Read the RWK Docs to learn more.

FAQ

Q: Can I use RWK with RPG Maker VX?
A: I created and tested (a lot) the script on XP, but there's no reason it wouldn't work on VX since it's completely independent from all Game classes, it uses only the core Ruby classes... I tested it briefly on VX and it looks like it's OK. There could be some incompatibility somewhere... but I don't think so =P Just remember to copy all the Scripts (the Docs pages aren't necessary) and copy AsyncHTTP.dll from the demo to your VX project.

Compatibility

RWK should be compatible with any normal scripts. The only way you could have a problem is if some script changes classes from the core Ruby library (like class Thread or class Proc), which (I think) is not frequent.

Credits and Thanks

Special thanks to Diovanni "AntiCasper" de Souza, for support and testing.

Terms and Conditions

RWK is released under Creative Commons BY license. That means you must give me credit for the script if you use or redistribute it.
Damnit, all the cool stuff comes out when I stop using RPG Maker. Nice work with this, I haven't had chance to try it out but it's certainly useful and looks a nice way of going about it.
Commodore Whynot wrote:
Damnit, all the cool stuff comes out when I stop using RPG Maker. Nice work with this, I haven't had chance to try it out but it's certainly useful and looks a nice way of going about it.


Thanks!

Right now I'm working on a more interesting Demo and on some helper methods that I didn't put in v1.0 because I wanted to release it fast.
So v1.0.1 should be online in a few days and you'll a better example of what you can do with this :)
OFF-TOPIC
Olá, também sou brasileiro, eu lhe enviei uma PM, duas na verdade, mas parece que estas não foram entregues, não sei porque, bom gostaria muito de conversar com você, tenho um proposta a lhe fazer, você tem e-mail ou MSN?
FYI: Awardspace web host, where I host the page accessed by the demo, seems to be down for a while, so the Demo might not work and you'll see Error 12029. The server should be online again soon.
New demo works ok.
Being unable to open RPG Maker right now, I ask...

What libraries did you use on the back end? Do you have a Socket class? Does it utilize Winsock? Where did you get the code, or did you write it yourself?

EDIT: I see, you made a compiled library and linked it. Could you share the source code for you AsyncHTTP.dll library?
rey meustrus wrote:
Being unable to open RPG Maker right now, I ask...

What libraries did you use on the back end? Do you have a Socket class? Does it utilize Winsock? Where did you get the code, or did you write it yourself?

EDIT: I see, you made a compiled library and linked it. Could you share the source code for you AsyncHTTP.dll library?


AsyncHTTP.dll uses the WinHTTP library. WinHTTP itself is waaay more powerful but waaay more complex, and I couldn't use it directly in Ruby because I need to give the methods a pointer-to-function, so I made this wrapper that I called AsyncHTTP. I coded it in C using Visual Studio 2008.
If you look at the Documentation of RWK, there is a description of the methods exported by the DLL.

About sharing the sources... well, I could, but they're not commented and may be a little confuse XD Just wait a few days and I will put them in (fairly) good order and post them here, probably together with RWK 1.1.
This looks very promising indeed... but everything I can think of utilizing this for kind of wants me to be able to access a mysql database with it, which I don't think I could with this... or is the script capable of handling that?

Either way, this is a great script, and I'll stand in the same line as rey and wyatt before me, as in not being able to use RMXP at the time, so posting the scripts in here seperately from the demo would be handy to give you some more fundamental feedback, rather than guesses. ^^

Keep up the good work!
BlueScope wrote:
This looks very promising indeed... but everything I can think of utilizing this for kind of wants me to be able to access a mysql database with it, which I don't think I could with this... or is the script capable of handling that?

Either way, this is a great script, and I'll stand in the same line as rey and wyatt before me, as in not being able to use RMXP at the time, so posting the scripts in here seperately from the demo would be handy to give you some more fundamental feedback, rather than guesses. ^^

Keep up the good work!


You couldn't directly access the database, but you can make a php (or any language you want) script running on a webserver that accesses the database, get/set the info you want and returns you the data. That's what i do in the demo. (The problem now is that awardspace, where I host the php script, is down for a week, so the demo won't work u.u)
For example, for version 1.1 I'm making a little "forum" that you read and write to from inside the game =D

About posting the scripts: there are a lot of them, and very long documentation. I could make a package with them in txt files, though. I'll do that.

EDIT:
Here they are: http://www.gust.projetorpgmaker.com/RWK1_0_txt.zip
Please read and review =D hahahaha
I tried very hard to make the docs useful and easy to understand. There are a lot of examples to show you want you can do and how.
RWK Version 1.1 Released

I fixed some bugs and added four useful helper methods for parsing GET and POST data and two HTTP Headers that are commonly used. Also, the V1.1 Demo has an interesting system to show the Kit's power: GusForum, an in-game forum system. It uses AWorks Input scripts for user input, REXML for XML processing (in external files) and RWK to connect to a web server and, using simple PHP scripts (that you can download below to install in your own web server), allow users to create threads and send messages that can be seen by other people through the internet. You are free to use and modify the GusForum scripts, just remember to credit me ;)

Also, I now realease the Source Code to AsyncHTTP.dll, for those of you who like some C code.

Downloads

Demo: http://www.gust.projetorpgmaker.com/RWK_1_1/RWK%201_1.rar
RWK Scripts in txt files: http://www.gust.projetorpgmaker.com/RWK_1_1/RWK%201_1_txt.rar
AsyncHTTP.dll Source Code: http://www.gust.projetorpgmaker.com/RWK_1_1/AsyncHTTP.src.rar
GusForum Server Scripts: http://www.gust.projetorpgmaker.com/RWK_1_1/GusForum_Server.rar
I'd really love to use this, but whenever i set it up to work with my webserver, all i get in the game window is

Error -> Invalid board id

Can anyone help?
I've setup the connect.php and the mysql database, and setup the scripts and executed the sql queries.
Oh, oh, sorry.
Here's the problem: You have to create a board in your DB table "board".
Use this code:
  1.  
  2. insert into board(name) values('name of your board')
  3.  
Expand to see the code.

Look at the table to see what's the created board ID and use that ID when creating Scene_Board.
My fault, I should have explained that in the instructions.

Let's make something clear: GusForum isn't a "serious" script. I mean, the purpose is just to show one thing you can do with RWK, so I didn't put a lot of effort on making GusForum bug-free (some people already found one bug... try pressing a NUMPAD key). You can use it, but you should probably work on it to make it better before releasing your game.
That's great thanks, everything connects :)
Just one more problem though.
Whenever i try and post anything, i get this error:

Error Sending: Query Failed

Any ideas on what's wrong?
Thanks in advance :)
That happens when you try to create a thread or send a post to an existing one?
Is there anything in your "thread" table right now?
This is what's in my Thread table at the moment:

Image

Those are the titles of the threads i sent from the Game.
The messages don't show, and neither do the times, but the Titles do which is weird.
Hmm
Are you sure you've run all the sql instructions?
When you create a new thread, it says "query failed" or "insert 2 failed"?
It looks like you are missing the add_post procedure, I think..
It's in the sql.txt file but I copy here:
  1.  
  2. DELIMITER $$
  3.  
  4. DROP PROCEDURE IF EXISTS `add_post`$$
  5. CREATE PROCEDURE add_post( IN ptid int, IN pauthor varchar(20), IN ptext varchar(200))
  6. BEGIN
  7.  
  8. INSERT INTO message(thread_id, author, text) VALUES (ptid, pauthor, ptext);
  9. update thread set last_post = SYSDATE() where thread.id = ptid;
  10.  
  11. END$$
  12.  
  13. DELIMITER ;
  14.  
Expand to see the code.
Sorry about all this :/

I get "Insert 2 failed" now.
Crazyninjaguy wrote:
Sorry about all this :/

I get "Insert 2 failed" now.


No problem =]
Have you checked the add_post sql code I posted in the previous post?
Yeah i copied and executed it exactly.
This is a really great script so far!
Just to let anyone who see the topic know:
Problem solved, it was an issue with permissions in the hosts database, not a problem with GusForum scripts.
Remeber, when you copy the php scripts to your host, remeber to set the correct user and password at the connect.php file to the ones you use to log into phpmyadmin.
Thanks for making this!

I will be using it soon. :D
Wow... that's just... great!

But I'm a noob to script, and how can I edit those script? XD

But all that scripts are necessary for that sort of chat room? And how to create a server (I'm a noob, sorry if you find some questions stupid...)?
First of all: you should never edit the script in the "RGSS Web Kit" section (unless, of course, you are an experienced programmer and knows exactly what you are doing). You should only use those classes and methods, without editing them. Read the DOCS to learn what each class/method do.

Second: Yeah, all those scripts in the "Gus Forum" section AND the AWorks input library are needed for that small chat room. But GusForum is actually just a little example of what you could do with RWK... It's not really meant to be used in games. Of course one could use it, but one should work to make it better and more stable. You see, that's why I said in the first post: "this isn't a script for people who don't know RGSS. RWK gives you a way to get online, but it's completely up to you to make it useful".

Third: A server for RWK is any HTTP server. A server for GusForum, though, can be created using the GusForum Server Scripts, available in the first post.
Say, I want to make a basic message of the day window in my titlescreen. What is the easiest way to accomplish this? Im no noob at RGSS and neither at PHP, but I just can't figure out how to do that.
Give a look at Example 8. You could do something like this:

  1. conn = $session.connect("your host")
  2.       path = "/motd.php" # this is the page that will provide the MOTD. A simple php "echo" is enough.
  3.       msg_file = "motd.txt"
  4.       callback = Proc.new() { |req, done, error|
  5.         req.close();
  6.         if !done
  7.           create_motd_window("Couldn't read MOTD");
  8.           File.delete(msg_file)
  9.           break
  10.         end
  11.         s = ""
  12.         File.open(msg_file) { |f|
  13.           f.each_line { |line| s += line }
  14.         }
  15.         File.delete(msg_file)
  16.         create_motd_window(s);
  17.       }
  18.      
  19.       conn.send_get_request(path,false,nil,msg_file,&callback)
  20.  
Expand to see the code.


Maybe there's some sintax error somewhere, but that's the idea.
Hi there,

All of the download links are now broken. Any chance this could be re-uploaded? I'd like the DLL source as well.

Thanks

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=69392