server push to desktop client

Richard Gaskin ambassador at fourthworld.com
Tue Nov 5 03:29:02 EST 2019


Phil Davis wrote:

 > I need to make a desktop app (Mac only for now) that receives pushed
 > data from a LC server. I've never done this - all the desktop <->
 > server interactions I've programmed have used the traditional client-
 > server model. So I'm looking for approaches/tips/ideas from anyone
 > who has experience with other approaches.

I'd stick with simple polling for this.  Anything else requires either 
opening a socket (with all the firewall/router changes needed to allow 
that), or creating a dependency on a separate process like push 
notifications, which would likely require LCB.

Polling can get the job done well enough, and is secure and requires no 
router changes or external dependencies.  And if down the road you find 
a convenient way to switch to something else you can change that part, 
but at least it lets you get it out the door now using reliable features 
and your existing skillset.


 > And maybe I'm making it too hard. Can FTP watch a server folder, and
 > detect and respond to the creation of a file in the folder? Maybe I
 > could use a method like that, if that's a capability of FTP.

You could poll from the client using FTP, but compared to HTTP it's a 
noisy protocol, with many more steps internally.  The inefficiency of 
FTP is more than offset by its utility when ad hoc access to remote file 
stores are needed.  But when the goal is more specific, HTTP will often 
beat it for both efficiency and client implementation cost every time.

On the server, an LC Server script that reports any changes to a folder 
from the last time it was called would be straightforward to write, give 
you reliably consistent results*, and would run quickly.


* Years ago when I was monitoring folders with FTP I learned more than I 
cared to about FTP date representations.  They vary.  A lot.  By 
different rules, according to a vastly flexible set of config options. 
So you can never know which server will use month-and-day only up to a 
certain cutoff, and then one of several month-day-year options for 
anything older.  Sometimes the cuttoff is a month.  Sometimes it's the 
year break.  Other times it's a specific number of days.  "Hey man, it's 
all about flexibility!" In all cases it can mean a listing in which date 
representations take on at least two different formats.

Even if you just had LC Server return "the detailed files" at least 
you'd have solid consistency in the format of every file, every time.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list