Author Topic: HTTP Request  (Read 386 times)


  • Newbie
  • *
  • Posts: 13
    • View Profile
HTTP Request
« on: August 22, 2016 »
Is there any possibility of some basic internet GET/POST functionality?

I feel that being able to connect my game to an internet server is the only real feature I find missing in NaaLaa. This would allow me to access remote databases and exchange data.

I spent most of the night trying to write my own extension but failed miserably. Visual C++ Express seems to have zero functionality for HTTP Requests outside of messing with CURL which won't compile because your SDK needs to compile as C and causes <cmath> errors. Not having a strong background of C or C++ I have given up trying.

Alternatively maybe you could provide some code so we could implement our own P2P server in PHP that NaaLaa's P2P library could connect to as a kind of signalling server to exchange data?

If we could have some basic functions like this for NaaLaa I really feel it would be the icing on the cake in terms of the features available.

Thank you.
« Last Edit: August 23, 2016 by cherbert »


  • Administrator
  • Hero Member
  • *****
  • Posts: 549
    • View Profile
Re: HTTP Request
« Reply #1 on: August 23, 2016 »
Yes there is, sort of. I do it extensively in the P2P library, where I store active lobbies in a mysql database and use php scripts to set and get data.

Use the function download, defined as:

Code: [Select]
function download(url$, filename$, bufferSize, timeOut)
url$ is the url and filename$ is the name of the file that will be created with the downloaded content. bufferSize is the maximum size of the downloaded file in bytes. The download will abort if it takes more than timeOut seconds. The function returns false on failure or true on success.

You can download and have a look at the p2p.txt sourcecode file to see it in action.

Edit:   download is part of the core, so you do not need to include p2p or any other library. Yes, I know ... I forgot to add it to the documentation :D
« Last Edit: August 23, 2016 by Marcus »