Page 1 of 1

Run a Stack on Server and communicate with it with a browser

Posted: Tue May 13, 2014 2:31 pm
by Kangaroo SW
Hello All

After reading the revUp article "Cool Cat Server" from David Williams here:

http://newsletters.livecode.com/novembe ... etter1.php

I was wondering :roll: if it is possible to take a snapshot of a stack running on a server
and directly interact with the snapshot from within a browser.

I wanted to find out what could be done (jus a fun project) and came up with a
stack containing two cards.

Since I had some graphics laying around from a previous project (iPhone) I used them,
to create the stack and the html (.lc) page.

How does it work:
The stack runs on the server and is never saved.
You could save the stack but then a new user would start with the
changes of the previous user. I decided to have a model where the stack is not saved.

Every user gets a new session (a fresh stack), necessary variables are stored on the server for
every session in what is called session variables. This makes it possible to have many concurrent
visitors, each independent of every other !

The buttons on the stack are actually images which are used as HTML maps
and trigger the relevant LiveCode scripts in the stack script.

I also wanted to try to download content from a different server (e.g. pictures)
and display it in my stack, this led me to the idea of making the mini game
on card one.
Card two just displays some environmental variables.


I hope that other people with more HTML5/Ajax knowledge can come up with smarter ideas
how to use this concept.

Curious :wink: ?

See it in action here:
http://serverstack.kangaroo.on-rev.com/ ... _server.lc


My goal was just a proof of concept. It helped me understand the interaction between stacks and server, and
I learnt a lot of new HTML5 commands and a lot about LiveCode Server.

If you come up with other ideas how to use this concept then please post your stacks
or links into this thread !


Enjoy 8)
Cheers
Rolf


PS: You need to put the image bg_overlay_iphone_bg.png into the folder called images (because of the 256kb upload limit I had to separate it)

PS2: If the update of HTML pages are slow at times then wait until I upgrade to a newer iPhone :D

Re: Run a Stack on Server and communicate with it with a bro

Posted: Tue May 13, 2014 4:11 pm
by bn
Hi Rolf,

that is pretty neat, some sort of server vodoo.

Congratulations.

If anybody wants to test his knowledge of who is who at Runrev try this out.

Kind regards

Bernd

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed May 14, 2014 1:25 am
by FourthWorld
Unfortunately the connection times out for me. :(

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed May 14, 2014 1:27 am
by Simon
Same for me, another in California.

Simon

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed May 14, 2014 6:30 am
by Kangaroo SW
@FourthWorld and @Simon

Thank you for your report. There seems to be a problem with the session files created on the Server.
The file is called "lcsessions.idx" and in my example is created in the folder "lc_sessions_folder".

As soon as I delete the file "lcsessions.idx" the stack works again ?!

I will contact support, seems to be a problem on pancake or LC-Server :oops: ? I have already reported
an other problem with session variables.

In the meantime, if you have an LC-Server installation just install my files from above and run it in your own setup.

I have deleted "lcsessions.idx" now, so the stack should work again :D .

Cheers
Rolf

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed Mar 18, 2015 12:46 pm
by andyh1234
This is still happening, has on-rev become an abandoned proect?

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed Mar 18, 2015 3:41 pm
by FourthWorld
andyh1234 wrote:This is still happening, has on-rev become an abandoned proect?
Rolf has noted 10 months ago that the problem he was experiencing with the work he'd written was resolved after deleting his "lcsessions.idx" file.

Did you mean to write a different question in a different forum section?

Questions about the company's On-Rev hosting service are probably better handled through On-Rev's support than through these user-to-user forums:
http://on-rev.com/support/contact-us/

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed Mar 18, 2015 3:53 pm
by andyh1234
Deleting the .idx file only temporarily fixes the problem.

Livecode creates a new one as soon as the sessions code is called again, and soon enough the sessions will fail again. Sometimes it can be as with as little as 6 session requests, or as many as 100 but it will always fail and lock the engine again. Deleting the file again fixes it, and we go round in circles.

If course, deleting the file also deletes all the references to the sessions files, thus making the sessions useless.

I think Im going to try to re-write the routine using cookies, but I would have hoped in over 10 months this would have been fixed.

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed Mar 18, 2015 4:03 pm
by FourthWorld
What did On-Rev support say when you wrote them?

Re: Run a Stack on Server and communicate with it with a bro

Posted: Wed Mar 18, 2015 4:08 pm
by andyh1234
Ive just done it now, ive given them all the paths to the files on my server as its hosted at on-rev so hopefully they will be able to fix it.

Re: Run a Stack on Server and communicate with it with a bro

Posted: Mon Feb 27, 2017 3:02 pm
by UKMC
Hi KangarooSW,

very nice function, congrats !!

Is this method working with any stack or just with some special ones ??

Do you have made further experience with this technique ?

It would be very nice to hear from you

Best regards


Ulrich