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

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

Postby 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/november/issue160/newsletter1.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/stack_on_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 70 times
Stack On Server.zip
(171.82 KiB) Downloaded 76 times
Kangaroo SW
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 24
Joined: Sat Jan 15, 2011 10:57 am

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

Postby 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
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3154
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

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

Postby FourthWorld » Wed May 14, 2014 1:25 am

Unfortunately the connection times out for me. :(
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5103
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

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

Postby 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!
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

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

Postby 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
Kangaroo SW
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 24
Joined: Sat Jan 15, 2011 10:57 am

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

Postby andyh1234 » Wed Mar 18, 2015 12:46 pm

This is still happening, has on-rev become an abandoned proect?
andyh1234
 
Posts: 376
Joined: Mon Aug 13, 2007 4:44 pm
Location: Sale UK / FL USA

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

Postby 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
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5103
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

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

Postby 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.
andyh1234
 
Posts: 376
Joined: Mon Aug 13, 2007 4:44 pm
Location: Sale UK / FL USA

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

Postby FourthWorld » Wed Mar 18, 2015 4:03 pm

What did On-Rev support say when you wrote them?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5103
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

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

Postby 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.
andyh1234
 
Posts: 376
Joined: Mon Aug 13, 2007 4:44 pm
Location: Sale UK / FL USA

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

Postby 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
UKMC
 
Posts: 47
Joined: Sun Jan 08, 2017 12:01 pm


Return to CGIs and the Server

Who is online

Users browsing this forum: No registered users and 1 guest