Page 1 of 1

tsNet mobile working or not?

Posted: Fri Sep 23, 2016 8:53 pm
by Gurgen
Hi forum,

I'm very happy with livecode tsNet new library, it's way faster than libURl and livecode GET, POST...

So I've written a code to download a list of files using tsNetGetFile, it's working well on desktop and dictionary says that "tsNetGetFile" is for android and iOS too, BUT!!! I can't get it to work in mobile.

Please help to figure out this.

See the code.

Regards,
Gurgen

Code: Select all

######################################################
# TS DONWLOAD
######################################################
local sDownloadList
local tsDownload


-------------------------------------------------------------------------------
# downloadList
# pList: the list of files to download
# pSettings: An array contains download info
#                    pSettings["callbackobjectid"] : the object id to send callback
#                    pSettings["savepath"] : the file path to save files in
#                    pSettings["url"] : server URL, finishing with slash
#                    pSettings["maxonce"] : the maximum number of files to download at once
# CHANGES
#                    09/22/2016: created
--------------------------------------------------------------------------------
command downloadList pList, pSettings
   -- Save to local variables
   put pList into sDownloadList
   put 0 into tsDownload["index"]
   
   put pSettings["callbackobjectid"] into tsDownload["callbackobjectid"]
   put pSettings["savepath"] into tsDownload["savepath"]
   put pSettings["url"] into tsDownload["url"]
   put pSettings["maxonce"] into tsDownload["maxonce"]
   put 1 into tsDownload["startline"]
   
   -- Start download
   downloadGroup
end downloadList
-------------------------------------------------------------------------------



-------------------------------------------------------------------------------
# downloadGroup
# CHANGES
#                    09/22/2016: created
--------------------------------------------------------------------------------
command downloadGroup
   -- Loop to download files at once
   repeat with tFile = 1 to tsDownload["maxonce"]
      put (tFile + tsDownload["startline"] - 1) into tLine
      put line tLine of sDownloadList into sMedia
      
      -- Download using TS
      put tsNetGetFile(tFile, (tsDownload["savepath"] & sMedia), (tsDownload["url"] & sMedia),,"downloadComplate") into tResult
      
      -- Save the download result
      if tResult is empty then 
         put "ok" into tsDownload["files"][sMedia]
      else
         put tResult into tsDownload["files"][sMedia]
      end if
   end repeat
end downloadGroup
-------------------------------------------------------------------------------



-------------------------------------------------------------------------------
# downloadComplate
# pID: the id of connection
# CHANGES
#                    09/22/2016: created
--------------------------------------------------------------------------------
command downloadComplate pID
   add 1 to tsDownload["index"]
   
   -- Close connection
   tsNetCloseConn pID
   
   -- Group done
   if tsDownload["index"] mod tsDownload["maxonce"] = 0 then
      
      -- Send a callback with downloaded files info
      dispatch "downloadComplate" to  tsDownload["callbackobjectid"] with tsDownload["files"]
      
      -- Set do not backup for android
      if the platform is "iPhone" then
         repeat for each key tMedia in tsDownload["files"]
            iphoneSetDoNotBackupFile (tsDownload["savepath"] & tMedia)
         end repeat
      end if
      
      -- Reset 
      put empty into tsDownload["files"]
      
      -- Download is finished
      if tsDownload["index"] > the number of lines of sDownloadList then
         dispatch "downloadFinished" to tsDownload["callbackobjectid"]
         exit downloadComplate
      end if
      
      -- Go to next file group
      add tsDownload["maxonce"] to tsDownload["startline"]
      
      -- Download
      downloadGroup
   end if
end downloadComplate
################################################################


Re: tsNet mobile working or not?

Posted: Fri Sep 23, 2016 10:08 pm
by LiveCode_Panos
Hi Gurgen,

Have you added the tsNet inclusion in the standalone?

Best,
Panos
--

Re: tsNet mobile working or not?

Posted: Sat Sep 24, 2016 9:10 am
by Gurgen
LiveCode_Panos wrote:Hi Gurgen,

Have you added the tsNet inclusion in the standalone?

Best,
Panos
--
Hi Panos,
Thanks for replay,

Yes I have. I have tryed with auto searching inclusions, with manual setting inclusions, tryed to call tsNetInit, no result, it just stops on tsNetGetFile. Also I have tryed with older version of LiveCode (8.0.1 DP3) and it's not working again.


Thanks,
Gurgen

Re: tsNet mobile working or not?

Posted: Mon Nov 07, 2016 5:19 pm
by bangkok
Same issue here.

-no problem with tsNet library on Windows (desktop) (i use mainly the tsNetPostSync command)

-however with Android... no luck.

(LiveCode Indy 8.1.1)

I've checked the permissions, the inclusions, and the network (with the same mobile app, I connect to a MySQL DB)... everything looks OK.

So is tsNet working with Android or not ?

Re: tsNet mobile working or not?

Posted: Tue Nov 08, 2016 5:48 pm
by jacque
Make sure you have also checked the Internet checkbox in the Android pane in standalone settings.

Re: tsNet mobile working or not?

Posted: Thu Nov 17, 2016 11:47 am
by bangkok
OK it was a bug, with LiveCode Indy (which I use) or Business Edition.

See :

http://quality.livecode.com/show_bug.cgi?id=18498

"We fixed this bug in LiveCode 8.1.2 RC-1"