Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: KAKAN on May 14, 2016, 10:03 AM

Title: How to handle HTTP GET request?
Post by: KAKAN on May 14, 2016, 10:03 AM
Well, I'm trying to handle a HTTP GET request to a website. How can I store the output?
Something like the AJAX request to get a XML, but in my case, JSON
How to do it? Any examples would be useful :)
Title: Re: How to handle HTTP GET request?
Post by: vito on May 14, 2016, 10:45 AM
Yep something as JSON.parse for vc-mp will be fine :D But I think you have to do it yourself :(
Title: Re: How to handle HTTP GET request?
Post by: KAKAN on May 14, 2016, 01:37 PM
Quote from: vito on May 14, 2016, 10:45 AMYep something as JSON.parse for vc-mp will be fine :D But I think you have to do it yourself :(
This is not about JSON.parse, I want to make a GET request to a HTTP server.
Title: Re: How to handle HTTP GET request?
Post by: vito on May 14, 2016, 02:19 PM
You need proxy like a php server or something else if this thing can read your vc-mp's database and make http requests.
No native way to do that.
Title: Re: How to handle HTTP GET request?
Post by: KAKAN on May 14, 2016, 04:11 PM
Quote from: vito on May 14, 2016, 02:19 PMYou need proxy like a php server or something else if this thing can read your vc-mp's database and make http requests.
No native way to do that.
What about sockets though? Using database and a HTTP handler to get a JSON data from a website is complete shit.
Title: Re: How to handle HTTP GET request?
Post by: Stormeus on May 14, 2016, 04:27 PM
Quote from: KAKAN on May 14, 2016, 04:11 PM
Quote from: vito on May 14, 2016, 02:19 PMYou need proxy like a php server or something else if this thing can read your vc-mp's database and make http requests.
No native way to do that.
What about sockets though? Using database and a HTTP handler to get a JSON data from a website is complete shit.

Already been done, but the source code is lost.
http://viceunderdogs.com/index.php?topic=3087.msg35628#msg35628

I honestly wouldn't recommend running an HTTP server off Squirrel sockets since each request you have to handle takes processing time away from the scripts and server core.
Title: Re: How to handle HTTP GET request?
Post by: KAKAN on May 14, 2016, 04:53 PM
Quote from: Stormeus on May 14, 2016, 04:27 PM
Quote from: KAKAN on May 14, 2016, 04:11 PM
Quote from: vito on May 14, 2016, 02:19 PMYou need proxy like a php server or something else if this thing can read your vc-mp's database and make http requests.
No native way to do that.
What about sockets though? Using database and a HTTP handler to get a JSON data from a website is complete shit.

Already been done, but the source code is lost.
http://viceunderdogs.com/index.php?topic=3087.msg35628#msg35628

I honestly wouldn't recommend running an HTTP server off Squirrel sockets since each request you have to handle takes processing time away from the scripts and server core.
Make it again pls, and also, I'm not going to run a HTTP server.
I'm trying to get a JSON from a page, which I think can be done from a sockets, but since, we can't change the connect string, it's not useful for me :(
Title: Re: How to handle HTTP GET request?
Post by: vito on May 14, 2016, 06:26 PM
Quote from: KAKAN on May 14, 2016, 04:11 PMWhat about sockets though? Using database and a HTTP handler to get a JSON data from a website is complete shit.
Compilte shit or nothing, simple choice for curret time xD
Title: Re: How to handle HTTP GET request?
Post by: ysc3839 on May 15, 2016, 12:37 AM
Quote from: . on Apr 19, 2016, 09:52 PM
Quote from: vcmptr on Apr 19, 2016, 09:39 PMHTTP page downloader. Like this (http://php.net/manual/en/function.file-get-contents.php). I've tried with sockets but I could not.

I have that planned for a module that wraps the Mongoose (https://github.com/cesanta/mongoose) library. It's still a work in progress but when finished, it should provide a fully functional HTTP server/client with support for web-sockets for real time live maps (no more jsoon files). As well as TCP and UDP communications.

However, I need to implement that in a way that doesn't affect the frame-rate.Which means I'd have to run it into a separate thread. And since Squirrel is not a thread safe language. I'm not sure how to achieve that without creating a bottleneck from all the context switching to communicate between threads. Which means that this module is still pending for now.

And I can't see any safe and decent way of going with this so I might spend a while until I come up with something.
Title: Re: How to handle HTTP GET request?
Post by: ysc3839 on May 15, 2016, 12:39 AM
Quote from: KAKAN on May 14, 2016, 04:53 PM
Quote from: Stormeus on May 14, 2016, 04:27 PM
Quote from: KAKAN on May 14, 2016, 04:11 PM
Quote from: vito on May 14, 2016, 02:19 PMYou need proxy like a php server or something else if this thing can read your vc-mp's database and make http requests.
No native way to do that.
What about sockets though? Using database and a HTTP handler to get a JSON data from a website is complete shit.

Already been done, but the source code is lost.
http://viceunderdogs.com/index.php?topic=3087.msg35628#msg35628

I honestly wouldn't recommend running an HTTP server off Squirrel sockets since each request you have to handle takes processing time away from the scripts and server core.
Make it again pls, and also, I'm not going to run a HTTP server.
I'm trying to get a JSON from a page, which I think can be done from a sockets, but since, we can't change the connect string, it's not useful for me :(
I think it's easy to do that.
Developers should fix the socket plugin's issue first. When the client send data to server, the server will crash. I have reported this months ago, but still havn't fixed yet.