Jump to content


Photo

Asynchronous Functions


  • Please log in to reply
74 replies to this topic

#61 Thaudal

Thaudal

    GMC Member

  • GMC Member
  • 235 posts
  • Version:GM:Studio

Posted 26 April 2012 - 08:35 PM

http_get() works on android and you should be able to communicate with a server... if you find a bug then please file it at http://bug.yoyogames.com

Russell


Does the app need to be hosted or something special like that, or can I just run directly from Studio beta to Android through cable and it'll work? Because it didn't seem to work, but if it's supposed to, then I guess I did something wrong. It'd just be nice to know if it's supposed to work before trying harder...

Edited by Elminster, 26 April 2012 - 08:36 PM.

  • 0

#62 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 11 May 2012 - 10:58 PM

(solved! check EDIT:)

I got http_get to work, it returned the information from my page as expected.
But I can't get http_post_string to work.
I can't even get the HTTP event to trigger.

I have this in my create event:
postString = ds_map_create()
ds_map_add(postString, 'submitForm', '1')
ds_map_add(postString, 'name', 'myName')
post[0] = http_post_string(my_url, ds_map_write(postString))

and my page looks like this:
<?php
if (isset($_POST["submitForm"]))
{
	echo "name: " . $_POST["name"];	
}
?>

<form action = "get_and.php" method = "post">
<input type = "text" name = "name">
<input type = "submit" name = "submitForm">
</form>

I guess I don't understand how to build the ds_map and how to build the page to return the correct information.


EDIT:
Lol... I've been reading this topic back and forth all night and I can't even remember what I have red... IMPs post was very helpfull!

I've changed my create event to:
post[0] = http_post_string(my_url, 'submitForm=1&name=Charlie')
And my page looks like this:
<?php
if (isset($_POST["submitForm"]))
{
	echo "name: " . $_POST["name"];	
}
?>
Notice that no <form> is needed, it's actually posted as a already filled form and not the needed inputs for a form, silly me :tongue:

I'll keep the first part of this post if anyone happend to get as confused as I was.

Edited by filulilus, 13 May 2012 - 10:33 PM.

  • 0

#63 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 13 May 2012 - 10:37 PM

Hmmm, I found another thing that is kinda strange, I can only get the HTTP event to trigger once.
The first time it returns the score like it supose to but the second time it dosen't repsond, any ideas?

// Create event
global.post[0] = -1


// Step event (with mouse press and so on...)
global.post[0] = http_post_string(myURL, 'submitGetScore=1') 


// HTTP event
switch async_load
{
    case global.post[0]:
    global.post[0] = -1
    show_message(ds_map_find_value(async_load, "result"))
    break
}

EDIT:
I know the HTTP request gets executed becouse I also save data (level, hp, mana and so on...) with PHP and MySQL and yeah... it gets saved.

Edited by filulilus, 14 May 2012 - 04:53 PM.

  • 0

#64 _257836

_257836

    GMC Member

  • New Member
  • 7 posts

Posted 24 May 2012 - 09:19 AM

the switch is wrong, it should be:
switch ds_map_find_value(async_load,"id")
...
instead of
switch async_load
...

  • 0

#65 TeamSteeve

TeamSteeve

    GMC Member

  • GMC Member
  • 883 posts
  • Version:GM:Studio

Posted 28 May 2012 - 12:46 AM

How far off is an async equivalent to the get_string and get_integer functions?
Just want to figure out whether it's worth waiting or if I should bother adding something to get user input another way.
  • 0

#66 Erik Leppen

Erik Leppen

    GMC Member

  • GMC Member
  • 2028 posts
  • Version:GM:Studio

Posted 07 June 2012 - 08:57 AM

How do I use this to load graphics from the local file system (Windows)?

I try background_add, but I'm not getting the async event - the whole event is simply not triggering.

b1 = background_add("C:\Temp\metal_background.png", false, false)

What am I doing wrong?

Edited by Erik Leppen, 07 June 2012 - 08:57 AM.

  • 0

#67 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16790 posts
  • Version:GM:Studio

Posted 07 June 2012 - 09:00 AM

As far as I am aware, in Windows, no async event is triggered when loading resources as it is not necessary...
  • 0

#68 Erik Leppen

Erik Leppen

    GMC Member

  • GMC Member
  • 2028 posts
  • Version:GM:Studio

Posted 07 June 2012 - 09:10 AM

OK, thanks. I got it to work. There was another bug at play that I'm now adding to Mantis......

Edited by Erik Leppen, 07 June 2012 - 09:14 AM.

  • 0

#69 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1571 posts
  • Version:GM:Studio

Posted 07 June 2012 - 07:01 PM

As far as I am aware, in Windows, no async event is triggered when loading resources as it is not necessary...

So on Windows do resources not actually load asynchronously then? :confused:
  • 0

#70 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1407 posts
  • Version:Unknown

Posted 07 June 2012 - 07:44 PM

No currently they do not in a supported fashion...

I have some test code in place on Windows but currently we are not supporting that as it has many issues that we do not have the time currently to address..

Russell
  • 0

#71 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 417 posts
  • Version:GM:Studio

Posted 03 July 2012 - 06:56 PM

No currently they do not in a supported fashion...

I have some test code in place on Windows but currently we are not supporting that as it has many issues that we do not have the time currently to address..

Russell


Yeah, like I said before, async functions for local files would be extremely useful. :)

Currently I can create a loading screen for example but it freezes the game every time it loads the next batch of files. That makes animated or responsive loading screens impossible. Also in the rare occasion if the user clicks on the game window while loading, Windows might pop the message that the app is unresponsive.

Another nice use of this would be background loading or loading as the player progresses through a map. This would make huge endless maps possible and seamless.
  • 0

#72 Pizzastron

Pizzastron

    GMC Member

  • GMC Member
  • 40 posts

Posted 01 November 2012 - 11:26 PM

This is driving me NUTS!!! I hardly managed to get 'http_get' to work, and I can't get 'http_post_string' to work properly. Nothing, absolutely NOTHING comes back ! async_load's "result" holds nothing at all... No data is coming back whatever I do ! I tried filulilus' solution, and it didn't work either.

I hate to say this because I love GM:S, but these functions are a pain in the neck and are unsufficiently documented, even the extended examples are not enough to let one sort it out easily. I hate these functions !

Sorry, but I'm switching back to GM AJAX, at least this one is much easier to use !

EDIT: Actually my PHP script sends back something, but doesn't spot anything in the $_POST variables, which means I can't do any treatment on the data sent. I don't get it... at all.

Edited by Pizzastron, 01 November 2012 - 11:35 PM.

  • 0

#73 Manuel777

Manuel777

    InvaderGames

  • GMC Member
  • 2847 posts
  • Version:GM:Studio

Posted 02 November 2012 - 01:03 AM

@pizzastron then you are doing something wrong.. probably the arguments you are sending are incorrect, remember that POST doesnt use the arguments in the URL like on GET, but in the string you send with the function..
  • 0

#74 locohost

locohost

    GMC Member

  • GMC Member
  • 459 posts
  • Version:GM:Studio

Posted 02 November 2012 - 01:29 AM

This is driving me NUTS!!! I hardly managed to get 'http_get' to work, and I can't get 'http_post_string' to work properly. Nothing, absolutely NOTHING comes back ! async_load's "result" holds nothing at all... No data is coming back whatever I do ! I tried filulilus' solution, and it didn't work either.

I hate to say this because I love GM:S, but these functions are a pain in the neck and are unsufficiently documented, even the extended examples are not enough to let one sort it out easily. I hate these functions !

Sorry, but I'm switching back to GM AJAX, at least this one is much easier to use !

EDIT: Actually my PHP script sends back something, but doesn't spot anything in the $_POST variables, which means I can't do any treatment on the data sent. I don't get it... at all.


I can't think of any good reason to switch away from GM AJAX to use the GM asynch http functionality. They're basically the same thing and you're right GM AJAX is a little easier. Stick with what you have.
  • 0

#75 Pizzastron

Pizzastron

    GMC Member

  • GMC Member
  • 40 posts

Posted 02 November 2012 - 02:14 PM

then you are doing something wrong


Manuel777, that's what always comes to my mind when my code doesn't work, and it sometimes takes a while before getting your code to work properly, I guess you know that. ;) But I tried all the ways I could think of to get 'http_post_string' to work, and in the end I lost my patience. I'm still wondering whether the problem lies in my code or in some sort of rare bug (which is very unlikely), but as I said, I tried every possible way I could think of to code it. Didn't want to work anyway, even filulilus' solution that seemed to work with his code didn't give any result to me... I don't want to spend any more time to try figuring out what's wrong. As I said, despite Yoyo's team's efforts, it isn't well documented enough to use these functions with ease. Thus, back to GM AJAX, which works perfectly.

So, thank you locohost, for reinforcing me in my opinion. I'm gonna stick to GM AJAX for a while. ;)

Edited by Pizzastron, 02 November 2012 - 05:55 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users