Page 1 of 1

I need a basic example of using a "Streaming App"

Posted: Fri Oct 07, 2016 3:29 am
by ghettocottage
In more than one post, Richard Gaskin has described a Streaming app (one example of a thread that touches on this: http://forums.livecode.com/viewtopic.ph ... 2&p=146017 )

Has anyone out there in Livecode land used this method successfully? If so, are you willing to post a basic example of this?

There is an example in Livecode 8, under plugins>GoLiveNet which is really great, but the script that downloads the stack and uncompresses it is rather complex and I would just like to do a simple starter for this before I attempt additional features. I picked through it a bit but have not quite managed to unlock the secrets just yet. I need a little help.

I have a remote server with Livecode 8 server on it. What will my script look like that downloads and opens the stack on my server, and then closes it when through?

Any help is appreciated!

Re: I need a basic example of using a "Streaming App"

Posted: Fri Oct 07, 2016 4:21 am
by FourthWorld
ghettocottage wrote:There is an example in Livecode 8, under plugins>GoLiveNet which is really great, but the script that downloads the stack and uncompresses it is rather complex and I would just like to do a simple starter for this before I attempt additional features. I picked through it a bit but have not quite managed to unlock the secrets just yet. I need a little help.
I should simplify that. It's old code that used to do more than it now needs to, and is needlessly complicated. My apologies.

Here's an exercise to get you started:

1. Upload a LiveCode stack file to a server

2. In your local Message Box, type

Code: Select all

go url "http://www.yourdomain.com/path/to/file.livecom"
If your stack is really large you can use the load command with a progress bar and other goodies, but in both of the two projects I run where we use downloaded stack I've found that since we're just downloading the stack file it's pretty small, and the "go" command works just fine by itself since the transfer time is usually just a second or two.

Re: I need a basic example of using a "Streaming App"

Posted: Fri Oct 07, 2016 4:47 am
by ghettocottage
Here's an exercise to get you started:

1. Upload a LiveCode stack file to a server

2. In your local Message Box, type

Code: Select all

 Select all
    go url "http://www.yourdomain.com/path/to/file.livecom"
Okay. I am kicking myself just now.

You had actually posted the same code in another thread, and I was trying that, and many variations with no luck. I figured I was missing some vital piece of information..

Turns out that I had added some rules in my .htaccess to prevent access to the stacks folder, and forgot to remove those rules when it came time to start working with the stacks.
I just removed those rules and my stacks pop-up immediately from that code.

Thanks!! Next time I will double check my server configuration before posting.

Re: I need a basic example of using a "Streaming App"

Posted: Fri Oct 07, 2016 5:05 am
by ghettocottage
I should simplify that. It's old code that used to do more than it now needs to, and is needlessly complicated. My apologies.
Just exploring the idea, and looking through your code, how far down would you simplify that if you were re-doing it?

It looks like it has some checks in case the download fails, or someone cancels the downloads, and then moves the launcher stack to the background and sets the downloaded stack to the front, and then some other things that I do not understand that look terribly impressive.

Re: I need a basic example of using a "Streaming App"

Posted: Fri Oct 07, 2016 3:49 pm
by ghettocottage
...have been spending more time playing around with the idea. I have to say this works very well, and has many advantages over having a static file that needs to be updated on every device it runs on.

Is there any down-side? I am trying to think through any possible issues:
  • *Since the application I am building relies on a remote database, it requires a connection regardless, so not being able to launch if there is no internet is not an issue.
  • *For security, I have this particular server only accessible via VPN, so the stack on the server is not publicly available.
  • *If I understand this concept correctly, the stack is downloaded temporarily to each device that opens it, so multiple people using it at once will not be an issue.

Re: I need a basic example of using a "Streaming App"

Posted: Fri Oct 07, 2016 7:36 pm
by FourthWorld
ghettocottage wrote:
  • *For security, I have this particular server only accessible via VPN, so the stack on the server is not publicly available.
VPN is a good option. In most of the projects I've used this on I also need authentication and other backend services, so I keep the stack files outside of the web root folder and serve them as binary files from an LC Server CGI.
  • *If I understand this concept correctly, the stack is downloaded temporarily to each device that opens it, so multiple people using it at once will not be an issue.
Yes, when a stack us loaded from a remote source it has no file name and exists only in RAM. And like a web page or most other network-delivered resources it's a copy of whatever's on the server, so each user has their own copy and they don't interfere with one another.

Re: I need a basic example of using a "Streaming App"

Posted: Mon Jul 03, 2017 11:24 pm
by ghettocottage
@FourthWorld
VPN is a good option. In most of the projects I've used this on I also need authentication and other backend services, so I keep the stack files outside of the web root folder and serve them as binary files from an LC Server CGI.
Richard,
I know this is an old thread, but I was wondering if you could elaborate a little on this comment that you serve the Livecode Stack as a binary file. Do you mean that you use a file-server rather than web-server on the VPN to serve the stacks?

Re: I need a basic example of using a "Streaming App"

Posted: Wed Jul 05, 2017 6:31 am
by FourthWorld
Web server. Given the lightweight simplicity of HTTP I rarely use anything else.

Just as a web server can read image files from disk and send them over the wire to the requesting client, they can deliver any other binary data the client app can handle. When that client is made with LC, stack files are a natural fit.

I'd you'd like I can turn up my version is mchttpd, socket server that handles HTTP. It's not great for production except maybe in very specialized setups, but it's a great way to learn how HTTP works so your can later use Apache, Lightly, Nginx, or anything else with confidence.

Re: I need a basic example of using a "Streaming App"

Posted: Wed Jul 05, 2017 9:07 pm
by ghettocottage
I'd you'd like I can turn up my version is mchttpd, socket server that handles HTTP. It's not great for production except maybe in very specialized setups, but it's a great way to learn how HTTP works so your can later use Apache, Lightly, Nginx, or anything else with confidence.
Yes, that would be great. So far I have a launcher app that uses:

Code: Select all

on openStack
   go url "https://db.myserver.com/stacks/db.livecode"      
   close stack "launcher"
end openStack
This works great, but I have not been able to figure out how to deliver those stacks from outside the webroot folder like you had mentioned.

Re: I need a basic example of using a "Streaming App"

Posted: Wed Jul 05, 2017 9:30 pm
by FourthWorld
Do you have LiveCode Server or other flexible scripting language set up as a CGI on your server?

Re: I need a basic example of using a "Streaming App"

Posted: Thu Jul 06, 2017 4:07 am
by ghettocottage
Do you have LiveCode Server or other flexible scripting language set up as a CGI on your server?
Indeed I do

Re: I need a basic example of using a "Streaming App"

Posted: Thu Jul 06, 2017 6:54 pm
by FourthWorld
Your CGI script can just read the file. Use binary mode, then just send it back to the requesting client using "put" like you would any other data.

Re: I need a basic example of using a "Streaming App"

Posted: Thu Jul 06, 2017 8:35 pm
by ghettocottage
FourthWorld wrote:Your CGI script can just read the file. Use binary mode, then just send it back to the requesting client using "put" like you would any other data.
Sorry, I have been experimenting but cannot seem to make this work. Can you give me an example of what the CGI script might look like?

Re: I need a basic example of using a "Streaming App"

Posted: Thu Jul 06, 2017 9:28 pm
by FourthWorld

Code: Select all

put url ("binfile:path/to/somestack.livecode) into tStackData
-- Always check for errors with file I/O:
if the result is not empty then
  put "Error: "& the result &&"("& sysError() ")"
  quit
end if
-- Deliver the goods:
put tStackData
quit

Re: I need a basic example of using a "Streaming App"

Posted: Thu Jul 06, 2017 10:20 pm
by ghettocottage
That works!

I was very close with the script I was trying, but I had to set permissions on the parent folder of where my external files are so the apache-user could have access (where webroot is /var/www/webroot and stacks are at /var/www/stacks)

fixed with
chown -R www-data:www-data /var/www &&chmod -R 775 /var/www

and now the CGI script loads the stack from a folder outside of the web-root.

Thank you so much!