Internet library syntax discussion

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9836
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Internet library syntax discussion

Post by FourthWorld » Mon Jun 08, 2015 3:24 pm

If all network I/O were non-blocking (add callbacks for POST) I won't care much what the syntax looks like, I'll just be happy. Seems I come across a request for a non-blocking POST almost once a month these days.

And I don't know if this is out of scope here, but it would be super-cool if LC could fork child processes in a way that lets us pass socket connections to them. With that we could not only support FastCGI, but also make all manner of efficient specialized app servers using faceless standalones.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7236
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Internet library syntax discussion

Post by jacque » Mon Jun 08, 2015 6:21 pm

I'm probably showing my ignorance here, but if all requests are nonblocking, how would we handle the cases where an app can't continue until the data is received?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Internet library syntax discussion

Post by SparkOut » Mon Jun 08, 2015 7:03 pm

By checking until the callback value is "complete" or appropriate. :)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7236
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Internet library syntax discussion

Post by jacque » Mon Jun 08, 2015 8:06 pm

SparkOut wrote:By checking until the callback value is "complete" or appropriate. :)
Right, but the user can do all sorts of things while I'm waiting for that. Do I have to lock down every possible user action? In my current project they should not be able to click any buttons, type into any fields, or anything else until the data is retrieved. I want everything to be blocked until the server returns the data.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9836
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Internet library syntax discussion

Post by FourthWorld » Mon Jun 08, 2015 9:18 pm

At the risk of sounding like a cranky old man, I like the setup we have now where most Internet things can be called using blocking or non-blocking syntax options. It would be ideal if we could maintain both going forward.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Internet library syntax discussion

Post by SparkOut » Mon Jun 08, 2015 11:14 pm

Would that be as simple as defining every request without a callback as blocking, and every request with a callback as nonblocking?

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Internet library syntax discussion

Post by trevordevore » Mon Jun 08, 2015 11:36 pm

SparkOut wrote:Would that be as simple as defining every request without a callback as blocking, and every request with a callback as nonblocking?
That is what I was thinking. While I try not to use blocking calls in my apps because LiveCode doesn't respond well to resizing the stack and other events, they make testing and quick tools much easier. Callbacks require a lot more code but offer a better user experience.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7236
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Internet library syntax discussion

Post by jacque » Tue Jun 09, 2015 7:52 pm

SparkOut wrote:Would that be as simple as defining every request without a callback as blocking, and every request with a callback as nonblocking?
That sounds like a workable approach to me. Then we have control.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Internet library syntax discussion

Post by trevordevore » Mon Jun 15, 2015 11:14 pm

The other thing to consider is how status is reported. Currently we parse headers to determine what the status code is. For headers we have libURLLastRHHeaders(). I think we should use the new approach that @LCMark has proposed (e.g. the message was handled), however. For example:

Code: Select all

the request error
the response header
the response status code
the response content type
Or maybe we treat the header as an object:

Code: Select all

the status code of the response header
the content type of the response header
An example:

Code: Select all

put url request "http://livecode.com" with headers tHeaders into tReturnedData
if the request error is not empty then
   switch the last response code
      case "404"
         ...
         break 
      case "401"
         ...
         break
      case empty
         -- no response received, error happened before server could respond.
         break
      default
         ...
   end switch
end if
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Internet library syntax discussion

Post by trevordevore » Fri Jul 03, 2015 9:16 pm

I neglected to mention that we need a way of getting a unique ID for async network operations. This allows us to cancel it if need be. Something like this:

Code: Select all

request url "http://livecode.com" with callback "MyCallback"
put the request id into sLastURLRequestId
cancel url request sLastURLRequestId
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply

Return to “LiveCode Builder”