I have not looked through the lua socket source code,but just from it's demo code from here http://w3.impa.br/~diego/software/luasocket/introduction.html it seems it's api is synchronous, and since all lua code runs on single thread in gideros as atilim said, how to use these socket api. In traditional network programme written in c/c++, we either call socket api on another thread or use asynchronous socket.
I have not looked through the lua socket source code,but just from it's demo code from here http://w3.impa.br/~diego/software/luasocket/introduction.html it seems it's api is synchronous, and since all lua code runs on single thread in gideros as atilim said, how to use these socket api.
I have not looked through the lua socket source code,but just from it's demo code from here http://w3.impa.br/~diego/software/luasocket/introduction.html it seems it's api is synchronous, and since all lua code runs on single thread in gideros as atilim said, how to use these socket api.
In the UrlLoader class the release notes say that you added support for headers. Is that for post and put only? I was hoping for a way to read the headers on get requests so I could check modified dates. Does UrlLoader use LuaSocket's HTTP stuff? If so I noticed there was a way to request only the header for a URL. Is there any advantage of using UrlLoader or socket.http?
I also assume to get https encryption I just use a url with "https" as the first parameter like UrlLoader.new("https://www.example.com").
Has anyone done socket programming? I once tried it was more work than I could put into it as the only dev of my game. I breifly looked at the LuaSockets docs and it looks slightly easier than the other library I tried. But I'm curious how other people use sockets? Do they setup a server that all clients would connect to? Or has anyone attempted peer-to-peer client discovery and connections like iOS's GameKit BlueTooth stuff? I heard that was implementation was very hackish and not a standard usage of BlueTooth.
And asyncronous is a problem for sure. I looked a copas and it said it was made for Lua 5.2 and I'm pretty sure Gideros uses Lua 5.1. It said to use coxpcall if you are using 5.1. http://coxpcall.luaforge.net/
Currently, we only support setting request headers and not reading response headers. And there is a good comment here http://bugs.giderosmobile.com/issues/95 that says we should support reading the response status and I totally agree.
UrlLoader is implemented differently for each platform (on desktop QNetworkAccessManager, on Android Apache HttpComponents and on iOS NSURLConnection) so that it can support HTTPS by using the underlying platform dependent capabilities.
On the other hand socket.http is a single platform independent implementation and maybe you can do HTTPS requests with LuaSec http://www.inf.puc-rio.br/~brunoos/luasec/
Are you sure Copas is for 5.2? Afaik, also LuaSocket hasn't ported to 5.2 yet.
"Since Copas is coroutine based, using it within a Lua pcall or xpcall context does not work with Lua 5.1 yielding. If you need to use any of those functions in your handler we strongly suggest using coxpcall, a coroutine safe version of the Lua 5.1 protected calls. For an example of this usage please check Xavante."
I assumed that meant that Copas was 5.2 but looking at the front page of Copas says 5.1 everywhere. I guess what it means is that Copas just isn't pcall or xpcall safe. And yesterday I couldn't remember what pcall was but now I do so it makes total sense that it doesn't work with yeild and "coxpcall" would be a solution. I just wasn't connecting the dots yesterday.
Comments
Likes: MoKaLux
Now let's start the storm of questions
Will the documentation for LuaSockets plugin will be available?
or is it completely the same?
http://w3.impa.br/~diego/software/luasocket/reference.html
Are there modifications needed for Gideros player to use it?
Doc will be updated (only a link to the reference you mention will be added).
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
gideros go, go, go!
Likes: MoKaLux
www.tntengine.com
May I suggest for a future release:
- Gideros Studio: settings to change the font and tab size.
- A function in Bitmap "class" to get the image as a PNG data string, something like:
Cheers!
:-))
https://sites.google.com/site/xraystudiogame
from here
http://w3.impa.br/~diego/software/luasocket/introduction.html
it seems it's api is synchronous, and since all lua code runs on single thread in gideros as atilim said, how to use these socket api.
In traditional network programme written in c/c++, we either call socket api on another thread or use asynchronous socket.
https://sites.google.com/site/xraystudiogame
Regarding the function, just open a new thread under "Suggestions & requests" as it may get lost in this thread.
https://sites.google.com/site/xraystudiogame
In the UrlLoader class the release notes say that you added support for headers. Is that for post and put only? I was hoping for a way to read the headers on get requests so I could check modified dates. Does UrlLoader use LuaSocket's HTTP stuff? If so I noticed there was a way to request only the header for a URL. Is there any advantage of using UrlLoader or socket.http?
I also assume to get https encryption I just use a url with "https" as the first parameter like UrlLoader.new("https://www.example.com").
Has anyone done socket programming? I once tried it was more work than I could put into it as the only dev of my game. I breifly looked at the LuaSockets docs and it looks slightly easier than the other library I tried. But I'm curious how other people use sockets? Do they setup a server that all clients would connect to? Or has anyone attempted peer-to-peer client discovery and connections like iOS's GameKit BlueTooth stuff? I heard that was implementation was very hackish and not a standard usage of BlueTooth.
And asyncronous is a problem for sure. I looked a copas and it said it was made for Lua 5.2 and I'm pretty sure Gideros uses Lua 5.1. It said to use coxpcall if you are using 5.1. http://coxpcall.luaforge.net/
Very cool stuff.
My apps: http://www.yummyyellow.com
Currently, we only support setting request headers and not reading response headers. And there is a good comment here http://bugs.giderosmobile.com/issues/95 that says we should support reading the response status and I totally agree.
UrlLoader is implemented differently for each platform (on desktop QNetworkAccessManager, on Android Apache HttpComponents and on iOS NSURLConnection) so that it can support HTTPS by using the underlying platform dependent capabilities.
On the other hand socket.http is a single platform independent implementation and maybe you can do HTTPS requests with LuaSec http://www.inf.puc-rio.br/~brunoos/luasec/
Are you sure Copas is for 5.2? Afaik, also LuaSocket hasn't ported to 5.2 yet.
I was wrong about Copas. What I read is on this url.
http://keplerproject.github.com/copas/manual.html
"Since Copas is coroutine based, using it within a Lua pcall or xpcall context does not work with Lua 5.1 yielding. If you need to use any of those functions in your handler we strongly suggest using coxpcall, a coroutine safe version of the Lua 5.1 protected calls. For an example of this usage please check Xavante."
I assumed that meant that Copas was 5.2 but looking at the front page of Copas says 5.1 everywhere. I guess what it means is that Copas just isn't pcall or xpcall safe. And yesterday I couldn't remember what pcall was but now I do so it makes total sense that it doesn't work with yeild and "coxpcall" would be a solution. I just wasn't connecting the dots yesterday.
My apps: http://www.yummyyellow.com