HTTP server Maker?

MeToo

  • Posts: 355
This might help you as a jump start:

This is a simple PHP script called helloworld.php that retrieves an attribute (by reading the REQUEST), stores it in a variable and responds with a "Hello World" and the attribute in simple string:
Code: [Select]
<?php // save file as "helloworld.php"
$param $_REQUEST['param'];
echo "Hello, World with param="$param
?>


This simple Stencyl code (placed in Scene events) calls the PHP (you have to change the URL to your local one) and draws the response on the Scene.
(Three local game attributes of type Text: <URL>, <param> and <response>)



NOTE: You have to deploy the game to your server where the PHP script is hosted, or you'll get a security warning and the game won't work.

I've been doing alright testing this in the browser, like you said.

Doing it in Stencyl is more complicated, and requires some work arounds.

I'm not able to test it in Flash due to some unresolved security sandbox issues (http://community.stencyl.com/index.php/topic,22735.msg132844.html#msg132844)

When it comes to HTML5 I can test it using files uploaded to dropbox, however dropbox doesn't seem to properly handle PHP files, so it simply loads up the whole contents of the .php file as the website response.

When I upload the PHP file to my server that I setup here on my local machine (using EasyPHP) the browser runs it just fine, including the special PHP stuff, and I've been able to play with that a little (thanks for the insight). However Stencyl HTML5 cannot connect to my server, using the same URL that the browser successfully uses. I have also uploaded PHP files to a few free online servers and find the same scenario, the browsers can connect, and handle the PHP just fine, but Stencyl HTML5 doesn't. It only seems to connect to the two dropbox links that I've tried (mine and the one in the Stencylpedia article).

I've also tried testing it as a windows app in stencyl. That works fine for my local server, and the free hosting sites, and dropbox (except for the PHP not doing it's special thing on dropbox, but that's a problem with dropbox).

I spent a lot of today trying to understand how I can get Stencyl to properly interact with anything other than dropbox, for now it looks like avoiding HTML5 and flash is the only option. I'm not sure if that's a problem with Stencyl, or something I'm overlooking. I am using the exact same Stencyl blocks to generate the windows version that works right, and the Flash and HTML5 versions that don't. I tried it on IOS using a remote web server, and the http requests work fine, including the php stuff.

Aside from my today's looking into Stencyl's HTTP requests I've been looking around for my best options on the actual backend. I'm coming to have a better understanding of PHP/MySQL, I'm learning more about it, and arranging things with the legitimate programmer portion of my team. This has been a very helpful thread for me, and I appreciate everyone's help, very much.

Going multi-player certainly involves a lot more learning, and a lot more doing, but I am encouraged, and I'm glad that I'm learning more about it.

Do you think that I should start a bug thread about these HTML5 HTTP request oddities?

captaincomic

  • *
  • Posts: 6108
Those problems are unrelated to Stencyl. Except maybe for this one: http://community.stencyl.com/index.php/topic,14561.0.html

For PHP files you need a PHP server, Dropbox is just for hosting static files. It won't handle scripts (of any server-side language).

I don't know how security is handled in HTML5, but for Flash it really must be solvable with either trusting the SWF or putting up a policy file. (I know I repeat myself, but what else can I say?)

sentenza

  • Posts: 55
I can confirm that HTTP requests work in flash as long as you put a proper crossdomain.xml file in the webserver root. How did you set up the server?

MeToo

  • Posts: 355
Those problems are unrelated to Stencyl. Except maybe for this one: http://community.stencyl.com/index.php/topic,14561.0.html

For PHP files you need a PHP server, Dropbox is just for hosting static files. It won't handle scripts (of any server-side language).

Thanks, Captain. I understand that Dropbox doesn't handle PHP properly, I mostly mention dropbox because it is the only one that HTML5 will interact with properly. I can make a windows Stencyl game using the exact same blocks for a server that's remote or local and it will handle it just fine.


I don't know how security is handled in HTML5,

I wouldn't be able to say for certain that it's a security problem with HTML5, it sure could be, I dont' get any kind of mention about a security error when trying to do the non dropbox servers.
In the case of HTML 5, when I test it, if it's the first time I've tried to reach out to a remote server since this loading of Stencyl, then Stencyl pops me up a warning (before proceeding to generate the file that says)

"Could not start web server since port 18524 is in use or blocked. On windows you may get a Windows firewall dialog" (I don't) "Click allow access to proceed"

but for Flash it really must be solvable with either trusting the SWF or putting up a policy file. (I know I repeat myself, but what else can I say?)


I remember what you said about flash, Captain. I'm trying to see if, as you said, someone on windows 7 can have a look, given that I'm not on Linux, and have already tried to tell flash to trust the entire C: directory, to no avail. As you said in the other thread (http://community.stencyl.com/index.php/topic,22735.msg132833.html#msg132833)

"Okay, I tried it now myself, and got the same error message until I trusted to SWF. No policy file (= crossdomain.xml) needed."

For me those Flash security errors still come up (when using flash player) and when using flash in the browser (using the same blocks that work for windows) Flash does the same thing HTML5 does, which is, nothing.

I can confirm that HTTP requests work in flash as long as you put a proper crossdomain.xml file in the webserver root. How did you set up the server?
Thanks Sentenza, are you on Linux? Windows 7? Other? I just uploaded the files that I wanted to access through the game to the servers, and gave the URL to a url Get block. Perhaps a Stencyl Flash game run on Windows 7 needs a crossdomain file where as a Stencyl Windows game run on windows 7 doesn't (my experience), or a flash game run on Linux doesn't (Captain's experience).

sentenza

  • Posts: 55
Thanks Sentenza, are you on Linux? Windows 7? Other? I just uploaded the files that I wanted to access through the game to the servers, and gave the URL to a url Get block. Perhaps a Stencyl Flash game run on Windows 7 needs a crossdomain file where as a Stencyl Windows game run on windows 7 doesn't (my experience), or a flash game run on Linux doesn't (Captain's experience).

I'm on linux. It's a check built in the flash library, I even tested it in a pure haxe app - the flash application won't connect to a server different from the one it's running on unless it can retrieve a policy file from it.

http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html

dripple

  • Posts: 747
I have tested my initial example in Flash and HTML5 on my Mac before I have posted it.
I also have written in red letters below the example that it needs to be run from the same server where the php-file is hosted. If you try to run the game inside Stencyl, it will not connect properly to the server without any policy tweaking due to some security contraints. This is the same issue with HTML5 publishing, as the game has to run from a webserver.

For this example, I used my local MAMP installation (XAMP, LAMP... whatever).

Don't make it to complicated:

Step 1:
- install XAMP or similar on windows, follow the instructions
- make sure that the installation works by opening a browser on your computer and access the local urls to your fresh installation
= this confirms that your Web server is installed and running

Step 2
- now copy the PHP-file from the example to a directory in your htdocs-Folder
- test the file by accessing it from the web-browser by typing in the given URL
= this confirmes that your Web server is delivering the PHP file

Step 3
- now publish your example game from stencyl, either Flash (Browser) or HTML5
- copy the files in the same folder then your PHP file from Step 2
- access the game by entering the URL (Server-URL plus Game-index-file)
= should work without any security constraints
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper

MeToo

  • Posts: 355
Thank you, Dripple. I hadn't missed the red text, and had done every single one of those things you list here (that post has been a great help, and definitely boosted my understanding of using Stencyl with http), but I must have made a mistake somewhere previously, being new to setting up servers. Probably I had previously put one or more files in the wrong folder.

It works now, and I feel very bad that my inexperience with setting up servers caused me to waste a bit of people's time looking into the possibility of bugs that didn't exist. Thank you for your help. Thanks everyone.

dripple

  • Posts: 747
Glad to hear that it works, MeToo.

So, no you have a working "Hello World" example to fill with life  :)
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper


WalrusMansion

  • Posts: 8
Hi guys. I'm working with a friend to make a very simple 2 player RTS with hidden information. I've been searching stencylpedia and these forums for solid advice on how to get the online multiplayer aspects working. In that regard, this thread is a gold mine that I've barely begun to process. I'll definitely be showing this to my partner, who has substantially more programming experience than I do (I don't know any code yet, but I understand Stencyl). I'd like to ask some of my own questions and I'm fairly confident that those of you who have been helping MeToo will be able to answer them, but I don't want to hijack this thread. What I'm thinking: I'll get to work on creating a thread for the game we're working on and post a link in here.  :)

MeToo

  • Posts: 355
You'll get no objection from me. I think small teams where Stencylers team up with server-makers is pretty exciting stuff. I think it has the potential to expand some horizons! :-)