Jump to content


Photo

HTTP Request Extension


  • Please log in to reply
12 replies to this topic

#1 Schalk

Schalk

    GMC Member

  • GMC Member
  • 487 posts
  • Version:GM:HTML5

Posted 29 December 2011 - 02:14 PM

Posted ImageHTTP Request Extension


This extension package provides networking functionality or ajax magic (I had to use that buzzword at least once in this documentation :P) for GameMaker:HTML5 games. This has been tested on IE, Firefox, Chrome, Opera. Hasn't been tested on any mobile devices.

Functions
Basic - Syncronized
http_get(url,async) - Sends a http get request to the server. url is the link you want to send the request to. async should be false. This will return the response. If the response is an error, an empty string will be returned, "".
http_post(url,params,async) - Sends a http post request to the server. url is the link you want to send the request to. params is the data you want to send, for example, "score=5&name=Bob". async should be false. This will return the response. If the response is an error, an empty string will be returned, "".

Advanced - Asyncronized
http_get(url,async) - Sends a http get request to the server. url is the link you want to send the request to. async should be true. This will return the handle of the request. This will be used to check when the request is ready or if it has can error.
http_post(url,params,async) - Sends a http post request to the server. url is the link you want to send the request to. params is the data you want to send, for example, "score=5&name=Bob". async should be true. This will return the handle of the request. This will be used to check when the request is ready or if it has can error.
http_check_ready(handle) - This will likely go in the step event, it checks where a request is ready. handle is the handle of the request. This will return true when ready, otherwise false will be returned.
http_check_error(handle) - This checks if the response was an error such as 404 page not found. handle is the handle of the request. This will return true if an error did occur, otherwise false will be returned. Only call this function once you know that the request is ready.
http_retrieve(handle) - Once you know that the request is ready, you can use this function to return the response of the request. If there was an error, the error code will be returned. If there wasn't an error, the response will be returned. handle is the handle of the request. AFTER USING THIS, SET THE HANDLE TO FALSE AS SHOW IN THE EXAMPLE BELOW.

Live Example
http://syntaxgames.c...r/http_request/

Links
http://syntaxgames.c...t_Extension.zip (direct)
http://www.crocko.co...t_Extension.zip (mirror)

Online Documentation
http://syntaxgames.c...umentation.html

Compatibility
I have slightly tested it on IE, Firefox, Opera and Chrome which it all seems to work on. I don't have a mobile device, so I wasn't able to test it on one.

License
Feel free to use and abuse as you wish. Credit appreciated though.
  • 0

#2 locohost

locohost

    GMC Member

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

Posted 03 January 2012 - 03:03 PM

Posted ImageHTTP Request Extension


This extension package provides networking functionality or ajax magic (I had to use that buzzword at least once in this documentation :P) for GameMaker:HTML5 games. This has been tested on IE, Firefox, Chrome, Opera. Hasn't been tested on any mobile devices.

Functions
Basic - Syncronized
http_get(url,async) - Sends a http get request to the server. url is the link you want to send the request to. async should be false. This will return the response. If the response is an error, an empty string will be returned, "".
http_post(url,params,async) - Sends a http post request to the server. url is the link you want to send the request to. params is the data you want to send, for example, "score=5&name=Bob". async should be false. This will return the response. If the response is an error, an empty string will be returned, "".

Advanced - Asyncronized
http_get(url,async) - Sends a http get request to the server. url is the link you want to send the request to. async should be true. This will return the handle of the request. This will be used to check when the request is ready or if it has can error.
http_post(url,params,async) - Sends a http post request to the server. url is the link you want to send the request to. params is the data you want to send, for example, "score=5&name=Bob". async should be true. This will return the handle of the request. This will be used to check when the request is ready or if it has can error.
http_check_ready(handle) - This will likely go in the step event, it checks where a request is ready. handle is the handle of the request. This will return true when ready, otherwise false will be returned.
http_check_error(handle) - This checks if the response was an error such as 404 page not found. handle is the handle of the request. This will return true if an error did occur, otherwise false will be returned. Only call this function once you know that the request is ready.
http_retrieve(handle) - Once you know that the request is ready, you can use this function to return the response of the request. If there was an error, the error code will be returned. If there wasn't an error, the response will be returned. handle is the handle of the request. AFTER USING THIS, SET THE HANDLE TO FALSE AS SHOW IN THE EXAMPLE BELOW.

Live Example
http://syntaxgames.c...r/http_request/

Links
http://syntaxgames.c...t_Extension.zip (direct)
http://www.crocko.co...t_Extension.zip (mirror)

Online Documentation
http://syntaxgames.c...umentation.html

Compatibility
I have slightly tested it on IE, Firefox, Opera and Chrome which it all seems to work on. I don't have a mobile device, so I wasn't able to test it on one.

License
Feel free to use and abuse as you wish. Credit appreciated though.


Can I ask a stupid question? I have a javascript library with a bunch of functions. Each function creates it's own new XmlHttpRequest object. Your code tries to reuse existing objects. What is the issue with the way I'm doing it versus yours? Is my library bad and/or a resource hog perhaps? :smile:
  • 0

#3 Metronome

Metronome

    GMC Member

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

Posted 20 February 2012 - 01:21 AM

Please Check Links !
  • 0

#4 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1483 posts
  • Version:GM:Studio

Posted 20 February 2012 - 08:26 AM

async http_get() and http_post_string() are coming in the next version. It uses HTML5 WEB events to allow full async communications with a proper callback - so no more polling!

(this will be available across the board in Studio as well BTW :whistle: )
  • 0

#5 Smarty

Smarty

    GMC Member

  • Retired Staff
  • 7213 posts
  • Version:GM:Studio

Posted 20 February 2012 - 09:13 AM

async http_get() and http_post_string() are coming in the next version. It uses HTML5 WEB events to allow full async communications with a proper callback - so no more polling!

Awesome - but what exactly do you mean by next version? You mean the next update, or a major version change? Or shorter, when can we expect this to be available? I was just busy implementing the Ajax approach through extensions so I'm interested to know.

Also, will it be possible to differentiate between two consecutive calls that call back the same event? For example, when I use the same get / post request twice I want to make sure which callback the event responds to without having to use different callback events (does it have an ID?).
  • 0

#6 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1483 posts
  • Version:GM:Studio

Posted 20 February 2012 - 10:39 AM

It'll be in the next update.

Yes, every GET/POST command you do returns you an ID, that way you have a "handle" so you know which one is which.
  • 0

#7 Smarty

Smarty

    GMC Member

  • Retired Staff
  • 7213 posts
  • Version:GM:Studio

Posted 20 February 2012 - 12:27 PM

Cool, that'll scratch a few things from my list. Cheers.
  • 0

#8 locohost

locohost

    GMC Member

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

Posted 20 February 2012 - 02:21 PM

async http_get() and http_post_string() are coming in the next version. It uses HTML5 WEB events to allow full async communications with a proper callback - so no more polling!

(this will be available across the board in Studio as well BTW :whistle: )


This is great news. I'm psyched :cool:
  • 0

#9 _235385

_235385

    GMC Member

  • New Member
  • 1 posts
  • Version:Unknown

Posted 04 March 2012 - 05:21 PM

It'll be in the next update.

Yes, every GET/POST command you do returns you an ID, that way you have a "handle" so you know which one is which.


Hi, maybe this is a stupid question, but after the http request how do I get the response?
Thanks to anyone who can help me.
  • 0

#10 greg74

greg74

    GMC Member

  • GMC Member
  • 20 posts
  • Version:GM:HTML5

Posted 05 March 2012 - 08:54 AM


It'll be in the next update.

Yes, every GET/POST command you do returns you an ID, that way you have a "handle" so you know which one is which.


Hi, maybe this is a stupid question, but after the http request how do I get the response?
Thanks to anyone who can help me.


I really would like to know this as well!
Anybody?
  • 0

#11 azcodon

azcodon

    GMC Member

  • GMC Member
  • 118 posts
  • Version:Unknown

Posted 05 March 2012 - 09:31 AM

Posted ImageHTTP Request Extension


This extension package provides networking functionality or ajax magic (I had to use that buzzword at least once in this documentation :P) for GameMaker:HTML5 games. This has been tested on IE, Firefox, Chrome, Opera. Hasn't been tested on any mobile devices.

Functions
Basic - Syncronized
http_get(url,async) - Sends a http get request to the server. url is the link you want to send the request to. async should be false. This will return the response. If the response is an error, an empty string will be returned, "".
http_post(url,params,async) - Sends a http post request to the server. url is the link you want to send the request to. params is the data you want to send, for example, "score=5&name=Bob". async should be false. This will return the response. If the response is an error, an empty string will be returned, "".

Advanced - Asyncronized
http_get(url,async) - Sends a http get request to the server. url is the link you want to send the request to. async should be true. This will return the handle of the request. This will be used to check when the request is ready or if it has can error.
http_post(url,params,async) - Sends a http post request to the server. url is the link you want to send the request to. params is the data you want to send, for example, "score=5&name=Bob". async should be true. This will return the handle of the request. This will be used to check when the request is ready or if it has can error.
http_check_ready(handle) - This will likely go in the step event, it checks where a request is ready. handle is the handle of the request. This will return true when ready, otherwise false will be returned.
http_check_error(handle) - This checks if the response was an error such as 404 page not found. handle is the handle of the request. This will return true if an error did occur, otherwise false will be returned. Only call this function once you know that the request is ready.
http_retrieve(handle) - Once you know that the request is ready, you can use this function to return the response of the request. If there was an error, the error code will be returned. If there wasn't an error, the response will be returned. handle is the handle of the request. AFTER USING THIS, SET THE HANDLE TO FALSE AS SHOW IN THE EXAMPLE BELOW.

Live Example
http://syntaxgames.c...r/http_request/

Links
http://syntaxgames.c...t_Extension.zip (direct)
http://www.crocko.co...t_Extension.zip (mirror)

Online Documentation
http://syntaxgames.c...umentation.html

Compatibility
I have slightly tested it on IE, Firefox, Opera and Chrome which it all seems to work on. I don't have a mobile device, so I wasn't able to test it on one.

License
Feel free to use and abuse as you wish. Credit appreciated though.


with GM4html5 you only load data synchronize,the reason is this Gm have to be completed the code in sort,if the first code not completed the second code donot run
  • 0

#12 Swast

Swast

    GMC Member

  • GMC Member
  • 25 posts

Posted 22 November 2012 - 04:24 PM

The download link leads to HTML5 extension.
This is the fixed and working one:
http://syntaxgames.c...t_Extension.zip
  • 0

#13 True Valhalla

True Valhalla

    ಠ_ಠ

  • Retired Staff
  • 4880 posts
  • Version:GM:Studio

Posted 14 February 2013 - 02:01 AM

Is this extension still relevant now that GM includes it's own solution? Pretty old topic.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users