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

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Kangaroo SW
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 33
Joined: Sat Jan 15, 2011 10:57 am

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

Post by Kangaroo SW » Tue May 13, 2014 2:31 pm

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
Attachments
bg_overlay_iphone_bg.png.zip
(134.98 KiB) Downloaded 469 times
Stack On Server.zip
(171.82 KiB) Downloaded 465 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3975
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

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

Post by bn » Tue May 13, 2014 4:11 pm

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

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

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

Post by FourthWorld » Wed May 14, 2014 1:25 am

Unfortunately the connection times out for me. :(
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

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

Post by Simon » Wed May 14, 2014 1:27 am

Same for me, another in California.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Kangaroo SW
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 33
Joined: Sat Jan 15, 2011 10:57 am

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

Post by Kangaroo SW » Wed May 14, 2014 6:30 am

@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

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

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

Post by andyh1234 » Wed Mar 18, 2015 12:46 pm

This is still happening, has on-rev become an abandoned proect?

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

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

Post by FourthWorld » Wed Mar 18, 2015 3:41 pm

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/
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

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

Post by andyh1234 » Wed Mar 18, 2015 3:53 pm

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.

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

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

Post by FourthWorld » Wed Mar 18, 2015 4:03 pm

What did On-Rev support say when you wrote them?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

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

Post by andyh1234 » Wed Mar 18, 2015 4:08 pm

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.

UKMC
Posts: 50
Joined: Sun Jan 08, 2017 12:01 pm

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

Post by UKMC » Mon Feb 27, 2017 3:02 pm

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

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

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

Post by sphere » Fri Nov 22, 2019 7:29 pm

This stack is awesome, it gives so much insight.
Sorry to respond on this older thread.
But it gives me new ideas on how to solve my current issues.
Thanks!

Post Reply

Return to “CGIs and the Server”