NetTalk Central

Author Topic: Timer in a Memory Form  (Read 4801 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Timer in a Memory Form
« on: June 12, 2017, 01:03:53 PM »
Hi Im using a calendar js in a Form and I need it to be refresh with a timer.
How can I do it?
Or better... every time another user modifies it
Any way?
Thanks
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Timer in a Memory Form
« Reply #1 on: June 12, 2017, 11:37:43 PM »
>> Or better... every time another user modifies it

That's what WebSockets are for. Much better than a timer.
see
http://www.capesoft.com/accessories/NetTalkUserGroup.htm
search for Web Sockets.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Timer in a Memory Form
« Reply #2 on: June 13, 2017, 06:36:36 PM »
Bruce, I search, view and try to understand the talkings about Web Sockets.
Then I open the WebSockets example.
My questions are:

- Are you suggesting me to add a Display field (HostValue) to tell the memory form that another user had modify the calendar? using the technic of the example?
And Can I refresh the calendar js when the host variable field in the form changes? may be adding code to the server side of this field?

-Then how do I set the server Host Variable value from a p_web object (the memory form which contains the calendar)? I cant use a session value because it will be only for the session user and may be thers many users modifiing the same calendar so, I think I need a Host variable. HOw to change it from the p_web memory form?

-Another problem is that there are Groups of users that modify the same calendar, let say you have 10 users connected, 3 are modiying cal1 , 3 mod cal2 and 4 mod cal 3, diference between calendars are only the filter of the events of each one cal.
Then may be I need many host variables, one for each group.
And... I need to set the name of this host variables at run time, because I dont know now whos connected or which filter the user will apply.
In other words I need a variable for each possible calendar filter applyed and, users that are applying the same filter, must receive the same host variable change.

As you can see... I need some more guidance, please

Thanks
« Last Edit: June 13, 2017, 07:18:23 PM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Timer in a Memory Form
« Reply #3 on: June 14, 2017, 05:30:25 AM »
Hi Alberto,

>> Are you suggesting me to add a Display field (HostValue) to tell the memory form that another user had modify the calendar?

that's one approach.
But I suspect you will need to make a JavaScript function which "watches" a host value, and then when a new host value arrives tells the calendar to do something.

look in nt-websockets.js
I haven't tried it but you'll basically do something similar to what the ntSockets.prototype.watch function does, but with a custom on message function.

I haven't tried it, but something like this;

function AlbertoWatchCalendar(url,scope,id,varname){
   if (varname == undefined){
      varname = id;
   }
   nts.open(url,
      function(i){ // on open
         _nts.sendText(i,'watch ' + scope + ' ' + varname);   
      },
      function(event,json,i){ // on message
         if (json[varname] !== undefined){
            //console.log('incoming data id=' + id + ' varname=' + varname + ' value=' + json[varname]);
                               // your javascript code to tell the calendar to refetch the data goes here.
         }      
      }   
   )
}


>> Then how do I set the server Host Variable value from a p_web object (the memory form which contains the calendar)?

p_web.SetHostValue('somename','somevalue')

>> Then may be I need many host variables, one for each group.

sure, you can make as many as you need.

cheers
Bruce





Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Timer in a Memory Form
« Reply #4 on: June 14, 2017, 05:51:18 AM »
Thanks but sory Im Learning js and Im not so good enought

Ive deleted the // from //console.log...... of the example, just to see what happens but nothing happens. Does it have to work? will help to see what Iam doing.

Looking at the Form Web Source of the example I see:

nts.watch("","hostvalue","#NumberOfUsers","usersonline");

and searching on how the nt clarion source does this line I found:

p_web.ntWatch('hostvalue', '#' & p_web.nocolon('FormControlUsersOnline') , 'UsersOnline')

and .ntWatch finally does a:

p_web.script('nts.Watch("","hostvalue","#' & p_web.nocolon('FormControlUsersOnline')&'","UsersOnline");')

which lead us to the resulting nts.watch("","hostvalue","#NumberOfUsers","usersonline");

Now,
1-how do I add that new function without editing the nt-websockets.js? can I add it as any script?

2-how do I call my (yours) new watch js proc from Clarion code and Where?
I suppouse using p_web.script(....) but how and where?


Thanks


« Last Edit: June 14, 2017, 11:23:36 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Timer in a Memory Form
« Reply #5 on: July 20, 2017, 09:36:24 PM »
Hi Alberto,

At the moment I'm concentrating on the NT10 release so not really able to digress to this sort of thing at this time. Also NT 10 has tweaks to the websockets system (and lots more docs) so you might find it easier to implement there.

cheers
Bruce