Asynchronous update from web server

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Asynchronous update from web server

dtrussardi@tiscali.it
Ciao,

I have a Seaside application.

I do not know the technical terms of my request ( sorry ).

I ask if it is possible to update a web client asynchronously directly from the server.

For now i manage the update from the client with the jquery load and relative interval: 10 seconds.

But this solution don't respond well at my problematic.

Thanks for considerations,

        Dario
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

CyrilFerlicot


On Sat 6 Apr 2019 at 15:56, [hidden email] <[hidden email]> wrote:
Ciao,

I have a Seaside application.

I do not know the technical terms of my request ( sorry ).

I ask if it is possible to update a web client asynchronously directly from the server.

For now i manage the update from the client with the jquery load and relative interval: 10 seconds

Hello, 

There is multiple way to do that. 

The first I know is, like you said, to make the client request the server from time to time.

The second is to use WebSockets (in Pharo there is an implementation in a special group of the Zinc project). WebSockets allows bi-directional communication between client and server.

The third one is Commet project I think but I never used it. I just know it exists. 

The cleaner and most used of the three is WebSockets I think. 


.

But this solution don't respond well at my problematic.

Thanks for considerations,

        Dario
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
--
Cyril Ferlicot
https://ferlicot.fr

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

dtrussardi@tiscali.it
Thanks  Cyril.



On Sat 6 Apr 2019 at 15:56, [hidden email] <[hidden email]> wrote:
Ciao,

I have a Seaside application.

I do not know the technical terms of my request ( sorry ).

I ask if it is possible to update a web client asynchronously directly from the server.

For now i manage the update from the client with the jquery load and relative interval: 10 seconds

Hello, 

There is multiple way to do that. 

The first I know is, like you said, to make the client request the server from time to time.

The second is to use WebSockets (in Pharo there is an implementation in a special group of the Zinc project). WebSockets allows bi-directional communication between client and server.

Any reference, example about it?

It's support , replicate into Gemstone environment?

The third one is Commet project I think but I never used it. I just know it exists. 

The cleaner and most used of the three is WebSockets I think. 

Thanks,
Dario

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

Esteban A. Maringolo
I implemented a mix of WebSockets with standard JS AJAX requests,
where I had a WS sending a message to the client which then triggered
a regular AJAX request to the seaside server.

In the end I discarded the WS and moved to a recursive setTimeout()
interval approach [1], because the screen that was updated "live"
didn't require more than an update per minute (it was a live map) and
most times the user moved on and off from that component faster than
that.

The reason to discard it was that the WS server was running in a
different port than the Seaside Server, and the setup of that wasn't
optimal for my taste. So it was more a proof of concept (which worked
just fine) than a recommended pattern.

And then the question is... what kind of update you want to "push" to
the client?

[1] setTimeout() is "better" than setInterval() because the call will
happen 60 seconds (or any duration) __after__ the last execution, this
is better for some use cases and in particular if you're debugging
something and it takes you more than the defined interval to send a
response to the client.

Esteban A. Maringolo

El sáb., 6 abr. 2019 a las 11:07, [hidden email]
(<[hidden email]>) escribió:

>
> Thanks  Cyril.
>
>
>
> On Sat 6 Apr 2019 at 15:56, [hidden email] <[hidden email]> wrote:
>>
>> Ciao,
>>
>> I have a Seaside application.
>>
>> I do not know the technical terms of my request ( sorry ).
>>
>> I ask if it is possible to update a web client asynchronously directly from the server.
>>
>> For now i manage the update from the client with the jquery load and relative interval: 10 seconds
>
>
> Hello,
>
> There is multiple way to do that.
>
> The first I know is, like you said, to make the client request the server from time to time.
>
> The second is to use WebSockets (in Pharo there is an implementation in a special group of the Zinc project). WebSockets allows bi-directional communication between client and server.
>
>
> Any reference, example about it?
>
> It's support , replicate into Gemstone environment?
>
>
> The third one is Commet project I think but I never used it. I just know it exists.
>
> The cleaner and most used of the three is WebSockets I think.
>
>
> Thanks,
> Dario
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

dtrussardi@tiscali.it
Ciao,

> I implemented a mix of WebSockets with standard JS AJAX requests,
> where I had a WS sending a message to the client which then triggered
> a regular AJAX request to the seaside server.
>
> In the end I discarded the WS and moved to a recursive setTimeout()
> interval approach [1], because the screen that was updated "live"
> didn't require more than an update per minute (it was a live map) and
> most times the user moved on and off from that component faster than
> that.
>
> The reason to discard it was that the WS server was running in a
> different port than the Seaside Server, and the setup of that wasn't
> optimal for my taste. So it was more a proof of concept (which worked
> just fine) than a recommended pattern.
>
> And then the question is... what kind of update you want to "push" to
> the client?

        In my case i haven't any user actions on the client.

        The client display some data with dynamic banner ( marquee tag )

        and i need to update it only when the data to display change from the server.

        When the data on the server relative to an banner change i need to force the clients banners update.

        it seems to me that your initial solution may be fine.

        What do you think?

        Another solution could be to manage an client ajax request with a specific interval  

        but  update the relative  banner div  only if the related data received from the server changed.

                ( But how i can manage it?

                 Can i not reply to an client ajax request
               
                        or respond to doing nothing and continue to view the current status )

        Thanks,

        Dario

>
> [1] setTimeout() is "better" than setInterval() because the call will
> happen 60 seconds (or any duration) __after__ the last execution, this
> is better for some use cases and in particular if you're debugging
> something and it takes you more than the defined interval to send a
> response to the client.
>
> Esteban A. Maringolo
>
> El sáb., 6 abr. 2019 a las 11:07, [hidden email]
> (<[hidden email]>) escribió:
>>
>> Thanks  Cyril.
>>
>>
>>
>> On Sat 6 Apr 2019 at 15:56, [hidden email] <[hidden email]> wrote:
>>>
>>> Ciao,
>>>
>>> I have a Seaside application.
>>>
>>> I do not know the technical terms of my request ( sorry ).
>>>
>>> I ask if it is possible to update a web client asynchronously directly from the server.
>>>
>>> For now i manage the update from the client with the jquery load and relative interval: 10 seconds
>>
>>
>> Hello,
>>
>> There is multiple way to do that.
>>
>> The first I know is, like you said, to make the client request the server from time to time.
>>
>> The second is to use WebSockets (in Pharo there is an implementation in a special group of the Zinc project). WebSockets allows bi-directional communication between client and server.
>>
>>
>> Any reference, example about it?
>>
>> It's support , replicate into Gemstone environment?
>>
>>
>> The third one is Commet project I think but I never used it. I just know it exists.
>>
>> The cleaner and most used of the three is WebSockets I think.
>>
>>
>> Thanks,
>> Dario
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

Esteban A. Maringolo
El lun., 8 abr. 2019 a las 7:48, [hidden email]
(<[hidden email]>) escribió:

>         In my case i haven't any user actions on the client.
>         The client display some data with dynamic banner ( marquee tag )
>         and i need to update it only when the data to display change from the server.
>         When the data on the server relative to an banner change i need to force the clients banners update.
>         it seems to me that your initial solution may be fine.
>
>         What do you think?

Too complex for such a simple task.

Is the <marquee> tag still a thing? I though it dissapeared when
Geocities closed. :)

See below my suggestion.


>         Another solution could be to manage an client ajax request with a specific interval
>         but  update the relative  banner div  only if the related data received from the server changed.
>                 ( But how i can manage it?
>                  Can i not reply to an client ajax request
>                         or respond to doing nothing and continue to view the current status )

You can have a recursive call to setInterval() that returns a script
(javascript) that updates the mentioned banner, and if no update is
necessary you do nothing. Doing it once per minute is nothing for the
server, since it's a simple AJAX call, which if nothing needs
updating, is fast to answer.

These are the key parts:

renderContentOn: html
  self renderBannerOn: html.
  html script: (html jQuery script: [ :script | self scriptUpdaterOn: script ])

scriptUpdaterOn: aJSScript
  aJSScript <<
    ((aJSScript jQuery ajax
      script: [ :s |
        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
        self scriptUpdaterOn: s ]) setTimeout: 1 minute)

scriptBannerUpdateOn: s
  s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn: h ])

Attached to this mails goes a working example of this.

In #scriptBannerUpdateOn: I would put all the logic, even by replacing
the whole component as a whole (sometimes the best compromise) or
indidividual elements within it).



Regards,

Esteban A. Maringolo

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

EAMRecursiveTimeout.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

Andy Burnett
In reply to this post by dtrussardi@tiscali.it
I have a feeling that Sven implemented Server Sent Events. If so, this might give you what you want


Cheers
Andy

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

dtrussardi@tiscali.it
In reply to this post by Esteban A. Maringolo
Ciao,

        thanks.

> El lun., 8 abr. 2019 a las 7:48, [hidden email]
> (<[hidden email]>) escribió:
>
>>        In my case i haven't any user actions on the client.
>>        The client display some data with dynamic banner ( marquee tag )
>>        and i need to update it only when the data to display change from the server.
>>        When the data on the server relative to an banner change i need to force the clients banners update.
>>        it seems to me that your initial solution may be fine.
>>
>>        What do you think?
>
> Too complex for such a simple task.
>
> Is the <marquee> tag still a thing? I though it dissapeared when
> Geocities closed. :)
>
> See below my suggestion.
>
>
>>        Another solution could be to manage an client ajax request with a specific interval
>>        but  update the relative  banner div  only if the related data received from the server changed.
>>                ( But how i can manage it?
>>                 Can i not reply to an client ajax request
>>                        or respond to doing nothing and continue to view the current status )
>
> You can have a recursive call to setInterval() that returns a script
> (javascript) that updates the mentioned banner, and if no update is
> necessary you do nothing. Doing it once per minute is nothing for the
> server, since it's a simple AJAX call, which if nothing needs
> updating, is fast to answer.
>
> These are the key parts:
>
> renderContentOn: html
>  self renderBannerOn: html.
>  html script: (html jQuery script: [ :script | self scriptUpdaterOn: script ])
>
> scriptUpdaterOn: aJSScript
>  aJSScript <<
>    ((aJSScript jQuery ajax
>      script: [ :s |
>        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
>        self scriptUpdaterOn: s ]) setTimeout: 1 minute)

        The setTimeout is not implemented in my system.

        With timeout:    i have some   problematic.

        I change the scriptUpdaterOn: aJSScript to:

        scriptUpdaterOn: aJSScript
                aJSScript <
  ((aJSScript jQuery ajax
     script: [ :s |
        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
                        ]) interval: 1 minute)

        It works very well relatively to my current needs.

        Dario

>
> scriptBannerUpdateOn: s
>  s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn: h ])
>
> Attached to this mails goes a working example of this.
>
> In #scriptBannerUpdateOn: I would put all the logic, even by replacing
> the whole component as a whole (sometimes the best compromise) or
> indidividual elements within it).
>
>
>
> Regards,
>
> Esteban A. Maringolo
> <EAMRecursiveTimeout.st>_______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

Esteban A. Maringolo
But using interval() is wrong. You're creating one new interval on every call! And it doesn't have to be recursive.

Maybe instead of #setInterval: it is #interval: in your image.

Regards,

El mar., 9 de abr. de 2019 11:30, [hidden email] <[hidden email]> escribió:
Ciao,

        thanks.

> El lun., 8 abr. 2019 a las 7:48, [hidden email]
> (<[hidden email]>) escribió:
>
>>        In my case i haven't any user actions on the client.
>>        The client display some data with dynamic banner ( marquee tag )
>>        and i need to update it only when the data to display change from the server.
>>        When the data on the server relative to an banner change i need to force the clients banners update.
>>        it seems to me that your initial solution may be fine.
>>
>>        What do you think?
>
> Too complex for such a simple task.
>
> Is the <marquee> tag still a thing? I though it dissapeared when
> Geocities closed. :)
>
> See below my suggestion.
>
>
>>        Another solution could be to manage an client ajax request with a specific interval
>>        but  update the relative  banner div  only if the related data received from the server changed.
>>                ( But how i can manage it?
>>                 Can i not reply to an client ajax request
>>                        or respond to doing nothing and continue to view the current status )
>
> You can have a recursive call to setInterval() that returns a script
> (javascript) that updates the mentioned banner, and if no update is
> necessary you do nothing. Doing it once per minute is nothing for the
> server, since it's a simple AJAX call, which if nothing needs
> updating, is fast to answer.
>
> These are the key parts:
>
> renderContentOn: html
>  self renderBannerOn: html.
>  html script: (html jQuery script: [ :script | self scriptUpdaterOn: script ])
>
> scriptUpdaterOn: aJSScript
>  aJSScript <<
>    ((aJSScript jQuery ajax
>      script: [ :s |
>        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
>        self scriptUpdaterOn: s ]) setTimeout: 1 minute)

        The setTimeout is not implemented in my system.

        With    timeout:    i have some   problematic.

        I change the             scriptUpdaterOn: aJSScript     to:

        scriptUpdaterOn: aJSScript
                aJSScript <
                         ((aJSScript jQuery ajax
                          script: [ :s |
                                        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
                        ]) interval: 1 minute)

        It works very well relatively to my current needs.

        Dario

>
> scriptBannerUpdateOn: s
>  s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn: h ])
>
> Attached to this mails goes a working example of this.
>
> In #scriptBannerUpdateOn: I would put all the logic, even by replacing
> the whole component as a whole (sometimes the best compromise) or
> indidividual elements within it).
>
>
>
> Regards,
>
> Esteban A. Maringolo
> <EAMRecursiveTimeout.st>_______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

dtrussardi@tiscali.it
Ciao,

But using interval() is wrong. You're creating one new interval on every call! And it doesn't have to be recursive.

Maybe instead of #setInterval: it is #interval: in your image.

You mean      timeout:  

But with: 

scriptUpdaterOn: aJSScript
                aJSScript <
                         ((aJSScript jQuery ajax
                          script: [ :s |
                                        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
                        ]) timeout: 1 minute)

i don't have any updating.

With:  scriptUpdaterOn: aJSScript
                 aJSScript <
                         ((aJSScript jQuery ajax
                          script: [ :s |
                                        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
   self scriptUpdaterOn: s
                         ]) timeout: 1 minute)

i have strange behavior.

The browser application go to 50% of CPU.

Thanks,

Dario

Regards,

El mar., 9 de abr. de 2019 11:30, [hidden email] <[hidden email]> escribió:
Ciao,

        thanks.

> El lun., 8 abr. 2019 a las 7:48, [hidden email]
> (<[hidden email]>) escribió:
>
>>        In my case i haven't any user actions on the client.
>>        The client display some data with dynamic banner ( marquee tag )
>>        and i need to update it only when the data to display change from the server.
>>        When the data on the server relative to an banner change i need to force the clients banners update.
>>        it seems to me that your initial solution may be fine.
>>
>>        What do you think?
>
> Too complex for such a simple task.
>
> Is the <marquee> tag still a thing? I though it dissapeared when
> Geocities closed. :)
>
> See below my suggestion.
>
>
>>        Another solution could be to manage an client ajax request with a specific interval
>>        but  update the relative  banner div  only if the related data received from the server changed.
>>                ( But how i can manage it?
>>                 Can i not reply to an client ajax request
>>                        or respond to doing nothing and continue to view the current status )
>
> You can have a recursive call to setInterval() that returns a script
> (javascript) that updates the mentioned banner, and if no update is
> necessary you do nothing. Doing it once per minute is nothing for the
> server, since it's a simple AJAX call, which if nothing needs
> updating, is fast to answer.
>
> These are the key parts:
>
> renderContentOn: html
>  self renderBannerOn: html.
>  html script: (html jQuery script: [ :script | self scriptUpdaterOn: script ])
>
> scriptUpdaterOn: aJSScript
>  aJSScript <<
>    ((aJSScript jQuery ajax
>      script: [ :s |
>        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
>        self scriptUpdaterOn: s ]) setTimeout: 1 minute)

        The setTimeout is not implemented in my system.

        With    timeout:    i have some   problematic.

        I change the             scriptUpdaterOn: aJSScript     to:

        scriptUpdaterOn: aJSScript
                aJSScript <
                         ((aJSScript jQuery ajax
                          script: [ :s |
                                        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
                        ]) interval: 1 minute)

        It works very well relatively to my current needs.

        Dario

>
> scriptBannerUpdateOn: s
>  s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn: h ])
>
> Attached to this mails goes a working example of this.
>
> In #scriptBannerUpdateOn: I would put all the logic, even by replacing
> the whole component as a whole (sometimes the best compromise) or
> indidividual elements within it).
>
>
>
> Regards,
>
> Esteban A. Maringolo
> <EAMRecursiveTimeout.st>_______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

Paul DeBruicker
Shouldn't your script have two < instead of one?  Like this:

scriptUpdaterOn: aJSScript
                aJSScript <<
                         ((aJSScript jQuery ajax
                          script: [ :s |
                                        self shouldUpdate ifTrue: [ self
scriptBannerUpdateOn: s ].
                        ]) timeout: 1 minute)




[hidden email] wrote

> Ciao,
>
>> But using interval() is wrong. You're creating one new interval on every
>> call! And it doesn't have to be recursive.
>>
>> Maybe instead of #setInterval: it is #interval: in your image.
>
> You mean      timeout:  
>
> But with:
>
>
> scriptUpdaterOn: aJSScript
>                 aJSScript <
>                          ((aJSScript jQuery ajax
>                           script: [ :s |
>                                         self shouldUpdate ifTrue: [ self
> scriptBannerUpdateOn: s ].
>                         ]) timeout: 1 minute)
>
> i don't have any updating.
>
> With: scriptUpdaterOn: aJSScript
>                 aJSScript <
>                         ((aJSScript jQuery ajax
>                          script: [ :s |
>                                         self shouldUpdate ifTrue: [ self
> scriptBannerUpdateOn: s ].
>   self scriptUpdaterOn: s
>                         ]) timeout: 1 minute)
>
> i have strange behavior.
>
> The browser application go to 50% of CPU.
>
> Thanks,
>
> Dario
>
>>
>> Regards,
>>
>> El mar., 9 de abr. de 2019 11:30,

> dtrussardi@

>  &lt;

> dtrussardi@

> &gt; escribió:
>> Ciao,
>>
>>         thanks.
>>
>> > El lun., 8 abr. 2019 a las 7:48,

> dtrussardi@

>> > (&lt;

> dtrussardi@

> &gt;) escribió:
>> >
>> >>        In my case i haven't any user actions on the client.
>> >>        The client display some data with dynamic banner ( marquee tag
>> )
>> >>        and i need to update it only when the data to display change
>> from the server.
>> >>        When the data on the server relative to an banner change i need
>> to force the clients banners update.
>> >>        it seems to me that your initial solution may be fine.
>> >>
>> >>        What do you think?
>> >
>> > Too complex for such a simple task.
>> >
>> > Is the
> <marquee>
>  tag still a thing? I though it dissapeared when
>> > Geocities closed. :)
>> >
>> > See below my suggestion.
>> >
>> >
>> >>        Another solution could be to manage an client ajax request with
>> a specific interval
>> >>        but  update the relative  banner div  only if the related data
>> received from the server changed.
>> >>                ( But how i can manage it?
>> >>                 Can i not reply to an client ajax request
>> >>                        or respond to doing nothing and continue to
>> view the current status )
>> >
>> > You can have a recursive call to setInterval() that returns a script
>> > (javascript) that updates the mentioned banner, and if no update is
>> > necessary you do nothing. Doing it once per minute is nothing for the
>> > server, since it's a simple AJAX call, which if nothing needs
>> > updating, is fast to answer.
>> >
>> > These are the key parts:
>> >
>> > renderContentOn: html
>> >  self renderBannerOn: html.
>> >  html script: (html jQuery script: [ :script | self scriptUpdaterOn:
>> script ])
>> >
>> > scriptUpdaterOn: aJSScript
>> >  aJSScript <<
>> >    ((aJSScript jQuery ajax
>> >      script: [ :s |
>> >        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
>> >        self scriptUpdaterOn: s ]) setTimeout: 1 minute)
>>
>>         The setTimeout is not implemented in my system.
>>
>>         With    timeout:    i have some   problematic.
>>
>>         I change the             scriptUpdaterOn: aJSScript     to:
>>
>>         scriptUpdaterOn: aJSScript
>>                 aJSScript <
>>                          ((aJSScript jQuery ajax
>>                           script: [ :s |
>>                                         self shouldUpdate ifTrue: [ self
>> scriptBannerUpdateOn: s ].
>>                         ]) interval: 1 minute)
>>
>>         It works very well relatively to my current needs.
>>
>>         Dario
>>
>> >
>> > scriptBannerUpdateOn: s
>> >  s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn:
>> h ])
>> >
>> > Attached to this mails goes a working example of this.
>> >
>> > In #scriptBannerUpdateOn: I would put all the logic, even by replacing
>> > the whole component as a whole (sometimes the best compromise) or
>> > indidividual elements within it).
>> >
>> >
>> >
>> > Regards,
>> >
>> > Esteban A. Maringolo
>> >
> <EAMRecursiveTimeout.st>
> _______________________________________________
>> > seaside mailing list
>> >

> seaside@.squeakfoundation

>> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>> _______________________________________________
>> seaside mailing list
>>

> seaside@.squeakfoundation

>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> _______________________________________________
>> seaside mailing list
>>

> seaside@.squeakfoundation

>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> _______________________________________________
> seaside mailing list

> seaside@.squeakfoundation

> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside





--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

dtrussardi@tiscali.it
Ciao,


> Shouldn't your script have two < instead of one?  Like this:

        it's an error in the email.

        The code is right,

                but with timeout:    the banner is not update.
       
                with interval:   it is update.

        considerations ?

        Thanks,
               
                Dario
               

>
> scriptUpdaterOn: aJSScript
>               aJSScript <<
>                         ((aJSScript jQuery ajax
>                          script: [ :s |
>                                        self shouldUpdate ifTrue: [ self
> scriptBannerUpdateOn: s ].
>                       ]) timeout: 1 minute)
>
>
>
>
> [hidden email] wrote
>> Ciao,
>>
>>> But using interval() is wrong. You're creating one new interval on every
>>> call! And it doesn't have to be recursive.
>>>
>>> Maybe instead of #setInterval: it is #interval: in your image.
>>
>> You mean      timeout:  
>>
>> But with:
>>
>>
>> scriptUpdaterOn: aJSScript
>>               aJSScript <
>>                         ((aJSScript jQuery ajax
>>                          script: [ :s |
>>                                        self shouldUpdate ifTrue: [ self
>> scriptBannerUpdateOn: s ].
>>                       ]) timeout: 1 minute)
>>
>> i don't have any updating.
>>
>> With: scriptUpdaterOn: aJSScript
>>               aJSScript <
>>                         ((aJSScript jQuery ajax
>>                          script: [ :s |
>>                                         self shouldUpdate ifTrue: [ self
>> scriptBannerUpdateOn: s ].
>>   self scriptUpdaterOn: s
>>                       ]) timeout: 1 minute)
>>
>> i have strange behavior.
>>
>> The browser application go to 50% of CPU.
>>
>> Thanks,
>>
>> Dario
>>
>>>
>>> Regards,
>>>
>>> El mar., 9 de abr. de 2019 11:30,
>
>> dtrussardi@
>
>> &lt;
>
>> dtrussardi@
>
>> &gt; escribió:
>>> Ciao,
>>>
>>>        thanks.
>>>
>>>> El lun., 8 abr. 2019 a las 7:48,
>
>> dtrussardi@
>
>>>> (&lt;
>
>> dtrussardi@
>
>> &gt;) escribió:
>>>>
>>>>>       In my case i haven't any user actions on the client.
>>>>>       The client display some data with dynamic banner ( marquee tag
>>> )
>>>>>       and i need to update it only when the data to display change
>>> from the server.
>>>>>       When the data on the server relative to an banner change i need
>>> to force the clients banners update.
>>>>>       it seems to me that your initial solution may be fine.
>>>>>
>>>>>       What do you think?
>>>>
>>>> Too complex for such a simple task.
>>>>
>>>> Is the
>> <marquee>
>> tag still a thing? I though it dissapeared when
>>>> Geocities closed. :)
>>>>
>>>> See below my suggestion.
>>>>
>>>>
>>>>>       Another solution could be to manage an client ajax request with
>>> a specific interval
>>>>>       but  update the relative  banner div  only if the related data
>>> received from the server changed.
>>>>>               ( But how i can manage it?
>>>>>                Can i not reply to an client ajax request
>>>>>                       or respond to doing nothing and continue to
>>> view the current status )
>>>>
>>>> You can have a recursive call to setInterval() that returns a script
>>>> (javascript) that updates the mentioned banner, and if no update is
>>>> necessary you do nothing. Doing it once per minute is nothing for the
>>>> server, since it's a simple AJAX call, which if nothing needs
>>>> updating, is fast to answer.
>>>>
>>>> These are the key parts:
>>>>
>>>> renderContentOn: html
>>>> self renderBannerOn: html.
>>>> html script: (html jQuery script: [ :script | self scriptUpdaterOn:
>>> script ])
>>>>
>>>> scriptUpdaterOn: aJSScript
>>>> aJSScript <<
>>>>   ((aJSScript jQuery ajax
>>>>     script: [ :s |
>>>>       self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
>>>>       self scriptUpdaterOn: s ]) setTimeout: 1 minute)
>>>
>>>        The setTimeout is not implemented in my system.
>>>
>>>        With    timeout:    i have some   problematic.
>>>
>>>        I change the             scriptUpdaterOn: aJSScript     to:
>>>
>>>        scriptUpdaterOn: aJSScript
>>>                aJSScript <
>>>                         ((aJSScript jQuery ajax
>>>                          script: [ :s |
>>>                                        self shouldUpdate ifTrue: [ self
>>> scriptBannerUpdateOn: s ].
>>>                        ]) interval: 1 minute)
>>>
>>>        It works very well relatively to my current needs.
>>>
>>>        Dario
>>>
>>>>
>>>> scriptBannerUpdateOn: s
>>>> s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn:
>>> h ])
>>>>
>>>> Attached to this mails goes a working example of this.
>>>>
>>>> In #scriptBannerUpdateOn: I would put all the logic, even by replacing
>>>> the whole component as a whole (sometimes the best compromise) or
>>>> indidividual elements within it).
>>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Esteban A. Maringolo
>>>>
>> <EAMRecursiveTimeout.st>
>> _______________________________________________
>>>> seaside mailing list
>>>>
>
>> seaside@.squeakfoundation
>
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>> _______________________________________________
>>> seaside mailing list
>>>
>
>> seaside@.squeakfoundation
>
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>> _______________________________________________
>>> seaside mailing list
>>>
>
>> seaside@.squeakfoundation
>
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>> _______________________________________________
>> seaside mailing list
>
>> seaside@.squeakfoundation
>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Seaside-General-f86180.html
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

Esteban A. Maringolo
Which version of Seaside are you using?

I can see that #timeout: is the deprecated implementation of the
#setTimeout: method of latest Seaside releases, and it instantiates a
JSTimeout object whose #javascriptContentOn: is as follows:

JSTimeout>>javascriptContentOn: aStream
  aStream nextPutAll: 'setTimeout(function(){'.
  super javascriptContentOn: aStream.
  aStream
    nextPutAll: '},';
    javascript: self duration;
    nextPut: $)


So in theory it should do the same thing.

Did you try my attached example replacing the #setTimeout: call by the
#timeout: equivalent?

Are you replacing the right DOM element in #scriptBannerUpdateOn: ?

Regards,

Esteban A. Maringolo

El mié., 10 abr. 2019 a las 12:36, [hidden email]
(<[hidden email]>) escribió:

>
> Ciao,
>
>
> > Shouldn't your script have two < instead of one?  Like this:
>
>         it's an error in the email.
>
>         The code is right,
>
>                 but with                 timeout:           the banner is not update.
>
>                 with             interval:      it is update.
>
>         considerations ?
>
>         Thanks,
>
>                 Dario
>
> >
> > scriptUpdaterOn: aJSScript
> >                  aJSScript <<
> >                         ((aJSScript jQuery ajax
> >                          script: [ :s |
> >                                        self shouldUpdate ifTrue: [ self
> > scriptBannerUpdateOn: s ].
> >                          ]) timeout: 1 minute)
> >
> >
> >
> >
> > [hidden email] wrote
> >> Ciao,
> >>
> >>> But using interval() is wrong. You're creating one new interval on every
> >>> call! And it doesn't have to be recursive.
> >>>
> >>> Maybe instead of #setInterval: it is #interval: in your image.
> >>
> >>      You mean      timeout:
> >>
> >>      But with:
> >>
> >>
> >>              scriptUpdaterOn: aJSScript
> >>                 aJSScript <
> >>                         ((aJSScript jQuery ajax
> >>                          script: [ :s |
> >>                                        self shouldUpdate ifTrue: [ self
> >> scriptBannerUpdateOn: s ].
> >>                         ]) timeout: 1 minute)
> >>
> >>              i don't have any updating.
> >>
> >>      With:   scriptUpdaterOn: aJSScript
> >>                              aJSScript <
> >>                               ((aJSScript jQuery ajax
> >>                                        script: [ :s |
> >>                                              self shouldUpdate ifTrue: [ self
> >> scriptBannerUpdateOn: s ].
> >>                                              self scriptUpdaterOn: s
> >>                         ]) timeout: 1 minute)
> >>
> >>      i have strange behavior.
> >>
> >>      The browser application go to 50% of CPU.
> >>
> >>      Thanks,
> >>
> >>              Dario
> >>
> >>>
> >>> Regards,
> >>>
> >>> El mar., 9 de abr. de 2019 11:30,
> >
> >> dtrussardi@
> >
> >> &lt;
> >
> >> dtrussardi@
> >
> >> &gt; escribió:
> >>> Ciao,
> >>>
> >>>        thanks.
> >>>
> >>>> El lun., 8 abr. 2019 a las 7:48,
> >
> >> dtrussardi@
> >
> >>>> (&lt;
> >
> >> dtrussardi@
> >
> >> &gt;) escribió:
> >>>>
> >>>>>       In my case i haven't any user actions on the client.
> >>>>>       The client display some data with dynamic banner ( marquee tag
> >>> )
> >>>>>       and i need to update it only when the data to display change
> >>> from the server.
> >>>>>       When the data on the server relative to an banner change i need
> >>> to force the clients banners update.
> >>>>>       it seems to me that your initial solution may be fine.
> >>>>>
> >>>>>       What do you think?
> >>>>
> >>>> Too complex for such a simple task.
> >>>>
> >>>> Is the
> >> <marquee>
> >> tag still a thing? I though it dissapeared when
> >>>> Geocities closed. :)
> >>>>
> >>>> See below my suggestion.
> >>>>
> >>>>
> >>>>>       Another solution could be to manage an client ajax request with
> >>> a specific interval
> >>>>>       but  update the relative  banner div  only if the related data
> >>> received from the server changed.
> >>>>>               ( But how i can manage it?
> >>>>>                Can i not reply to an client ajax request
> >>>>>                       or respond to doing nothing and continue to
> >>> view the current status )
> >>>>
> >>>> You can have a recursive call to setInterval() that returns a script
> >>>> (javascript) that updates the mentioned banner, and if no update is
> >>>> necessary you do nothing. Doing it once per minute is nothing for the
> >>>> server, since it's a simple AJAX call, which if nothing needs
> >>>> updating, is fast to answer.
> >>>>
> >>>> These are the key parts:
> >>>>
> >>>> renderContentOn: html
> >>>> self renderBannerOn: html.
> >>>> html script: (html jQuery script: [ :script | self scriptUpdaterOn:
> >>> script ])
> >>>>
> >>>> scriptUpdaterOn: aJSScript
> >>>> aJSScript <<
> >>>>   ((aJSScript jQuery ajax
> >>>>     script: [ :s |
> >>>>       self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
> >>>>       self scriptUpdaterOn: s ]) setTimeout: 1 minute)
> >>>
> >>>        The setTimeout is not implemented in my system.
> >>>
> >>>        With    timeout:    i have some   problematic.
> >>>
> >>>        I change the             scriptUpdaterOn: aJSScript     to:
> >>>
> >>>        scriptUpdaterOn: aJSScript
> >>>                aJSScript <
> >>>                         ((aJSScript jQuery ajax
> >>>                          script: [ :s |
> >>>                                        self shouldUpdate ifTrue: [ self
> >>> scriptBannerUpdateOn: s ].
> >>>                        ]) interval: 1 minute)
> >>>
> >>>        It works very well relatively to my current needs.
> >>>
> >>>        Dario
> >>>
> >>>>
> >>>> scriptBannerUpdateOn: s
> >>>> s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn:
> >>> h ])
> >>>>
> >>>> Attached to this mails goes a working example of this.
> >>>>
> >>>> In #scriptBannerUpdateOn: I would put all the logic, even by replacing
> >>>> the whole component as a whole (sometimes the best compromise) or
> >>>> indidividual elements within it).
> >>>>
> >>>>
> >>>>
> >>>> Regards,
> >>>>
> >>>> Esteban A. Maringolo
> >>>>
> >> <EAMRecursiveTimeout.st>
> >> _______________________________________________
> >>>> seaside mailing list
> >>>>
> >
> >> seaside@.squeakfoundation
> >
> >>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>>
> >>> _______________________________________________
> >>> seaside mailing list
> >>>
> >
> >> seaside@.squeakfoundation
> >
> >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>> _______________________________________________
> >>> seaside mailing list
> >>>
> >
> >> seaside@.squeakfoundation
> >
> >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>
> >>
> >> _______________________________________________
> >> seaside mailing list
> >
> >> seaside@.squeakfoundation
> >
> >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
> >
> >
> >
> >
> > --
> > Sent from: http://forum.world.st/Seaside-General-f86180.html
> > _______________________________________________
> > seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

dtrussardi@tiscali.it

> Which version of Seaside are you using?
       
        I using the Seaside 3.2.2   on Pharo 7.0-64-1262


> I can see that #timeout: is the deprecated implementation of the
> #setTimeout: method of latest Seaside releases, and it instantiates a
> JSTimeout object whose #javascriptContentOn: is as follows:

        The following code is identical

> JSTimeout>>javascriptContentOn: aStream
>  aStream nextPutAll: 'setTimeout(function(){'.
>  super javascriptContentOn: aStream.
>  aStream
>    nextPutAll: '},';
>    javascript: self duration;
>    nextPut: $)
>
> So in theory it should do the same thing.
>
> Did you try my attached example replacing the #setTimeout: call by the
> #timeout: equivalent?

        Yes, don't works
>
> Are you replacing the right DOM element in #scriptBannerUpdateOn: ?

        Yes.  With interval:  is right update ( therefore the reference is correct )



        But which libraries should I add when register the application?

        I register it with:

                app := WAAdmin register: self asApplicationAt: 'recursiveTimeout'.
       
                app addLibrary: JQDevelopmentLibrary

        it's right?

        Thanks,

                Dario

> Regards,
>
> Esteban A. Maringolo
>
> El mié., 10 abr. 2019 a las 12:36, [hidden email]
> (<[hidden email]>) escribió:
>>
>> Ciao,
>>
>>
>>> Shouldn't your script have two < instead of one?  Like this:
>>
>>        it's an error in the email.
>>
>>        The code is right,
>>
>>                but with                 timeout:           the banner is not update.
>>
>>                with             interval:      it is update.
>>
>>        considerations ?
>>
>>        Thanks,
>>
>>                Dario
>>
>>>
>>> scriptUpdaterOn: aJSScript
>>>                 aJSScript <<
>>>                        ((aJSScript jQuery ajax
>>>                         script: [ :s |
>>>                                       self shouldUpdate ifTrue: [ self
>>> scriptBannerUpdateOn: s ].
>>>                         ]) timeout: 1 minute)
>>>
>>>
>>>
>>>
>>> [hidden email] wrote
>>>> Ciao,
>>>>
>>>>> But using interval() is wrong. You're creating one new interval on every
>>>>> call! And it doesn't have to be recursive.
>>>>>
>>>>> Maybe instead of #setInterval: it is #interval: in your image.
>>>>
>>>>     You mean      timeout:
>>>>
>>>>     But with:
>>>>
>>>>
>>>>             scriptUpdaterOn: aJSScript
>>>>                aJSScript <
>>>>                        ((aJSScript jQuery ajax
>>>>                         script: [ :s |
>>>>                                       self shouldUpdate ifTrue: [ self
>>>> scriptBannerUpdateOn: s ].
>>>>                        ]) timeout: 1 minute)
>>>>
>>>>             i don't have any updating.
>>>>
>>>>     With:   scriptUpdaterOn: aJSScript
>>>>                             aJSScript <
>>>>                              ((aJSScript jQuery ajax
>>>>                                       script: [ :s |
>>>>                                             self shouldUpdate ifTrue: [ self
>>>> scriptBannerUpdateOn: s ].
>>>>                                             self scriptUpdaterOn: s
>>>>                        ]) timeout: 1 minute)
>>>>
>>>>     i have strange behavior.
>>>>
>>>>     The browser application go to 50% of CPU.
>>>>
>>>>     Thanks,
>>>>
>>>>             Dario
>>>>
>>>>>
>>>>> Regards,
>>>>>
>>>>> El mar., 9 de abr. de 2019 11:30,
>>>
>>>> dtrussardi@
>>>
>>>> &lt;
>>>
>>>> dtrussardi@
>>>
>>>> &gt; escribió:
>>>>> Ciao,
>>>>>
>>>>>       thanks.
>>>>>
>>>>>> El lun., 8 abr. 2019 a las 7:48,
>>>
>>>> dtrussardi@
>>>
>>>>>> (&lt;
>>>
>>>> dtrussardi@
>>>
>>>> &gt;) escribió:
>>>>>>
>>>>>>>      In my case i haven't any user actions on the client.
>>>>>>>      The client display some data with dynamic banner ( marquee tag
>>>>> )
>>>>>>>      and i need to update it only when the data to display change
>>>>> from the server.
>>>>>>>      When the data on the server relative to an banner change i need
>>>>> to force the clients banners update.
>>>>>>>      it seems to me that your initial solution may be fine.
>>>>>>>
>>>>>>>      What do you think?
>>>>>>
>>>>>> Too complex for such a simple task.
>>>>>>
>>>>>> Is the
>>>> <marquee>
>>>> tag still a thing? I though it dissapeared when
>>>>>> Geocities closed. :)
>>>>>>
>>>>>> See below my suggestion.
>>>>>>
>>>>>>
>>>>>>>      Another solution could be to manage an client ajax request with
>>>>> a specific interval
>>>>>>>      but  update the relative  banner div  only if the related data
>>>>> received from the server changed.
>>>>>>>              ( But how i can manage it?
>>>>>>>               Can i not reply to an client ajax request
>>>>>>>                      or respond to doing nothing and continue to
>>>>> view the current status )
>>>>>>
>>>>>> You can have a recursive call to setInterval() that returns a script
>>>>>> (javascript) that updates the mentioned banner, and if no update is
>>>>>> necessary you do nothing. Doing it once per minute is nothing for the
>>>>>> server, since it's a simple AJAX call, which if nothing needs
>>>>>> updating, is fast to answer.
>>>>>>
>>>>>> These are the key parts:
>>>>>>
>>>>>> renderContentOn: html
>>>>>> self renderBannerOn: html.
>>>>>> html script: (html jQuery script: [ :script | self scriptUpdaterOn:
>>>>> script ])
>>>>>>
>>>>>> scriptUpdaterOn: aJSScript
>>>>>> aJSScript <<
>>>>>>  ((aJSScript jQuery ajax
>>>>>>    script: [ :s |
>>>>>>      self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
>>>>>>      self scriptUpdaterOn: s ]) setTimeout: 1 minute)
>>>>>
>>>>>       The setTimeout is not implemented in my system.
>>>>>
>>>>>       With    timeout:    i have some   problematic.
>>>>>
>>>>>       I change the             scriptUpdaterOn: aJSScript     to:
>>>>>
>>>>>       scriptUpdaterOn: aJSScript
>>>>>               aJSScript <
>>>>>                        ((aJSScript jQuery ajax
>>>>>                         script: [ :s |
>>>>>                                       self shouldUpdate ifTrue: [ self
>>>>> scriptBannerUpdateOn: s ].
>>>>>                       ]) interval: 1 minute)
>>>>>
>>>>>       It works very well relatively to my current needs.
>>>>>
>>>>>       Dario
>>>>>
>>>>>>
>>>>>> scriptBannerUpdateOn: s
>>>>>> s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn:
>>>>> h ])
>>>>>>
>>>>>> Attached to this mails goes a working example of this.
>>>>>>
>>>>>> In #scriptBannerUpdateOn: I would put all the logic, even by replacing
>>>>>> the whole component as a whole (sometimes the best compromise) or
>>>>>> indidividual elements within it).
>>>>>>
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Esteban A. Maringolo
>>>>>>
>>>> <EAMRecursiveTimeout.st>
>>>> _______________________________________________
>>>>>> seaside mailing list
>>>>>>
>>>
>>>> seaside@.squeakfoundation
>>>
>>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>
>>>>> _______________________________________________
>>>>> seaside mailing list
>>>>>
>>>
>>>> seaside@.squeakfoundation
>>>
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>> _______________________________________________
>>>>> seaside mailing list
>>>>>
>>>
>>>> seaside@.squeakfoundation
>>>
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>
>>>>
>>>> _______________________________________________
>>>> seaside mailing list
>>>
>>>> seaside@.squeakfoundation
>>>
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Sent from: http://forum.world.st/Seaside-General-f86180.html
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

Esteban A. Maringolo
The library is fine and the JQDevelopmentLibrary is just for the
replacement, the setTimeout() and interval() are part of the built-in
functions in all browsers and comes in the Javascript package of
Seaside itself.

Can you share the code you're using? Is it exactly the same example I
sent a few mails back?

Regards,

Esteban A. Maringolo


El mié., 10 abr. 2019 a las 14:05, [hidden email]
(<[hidden email]>) escribió:

>
>
> > Which version of Seaside are you using?
>
>         I using the Seaside 3.2.2   on Pharo 7.0-64-1262
>
>
> > I can see that #timeout: is the deprecated implementation of the
> > #setTimeout: method of latest Seaside releases, and it instantiates a
> > JSTimeout object whose #javascriptContentOn: is as follows:
>
>         The following code is identical
>
> > JSTimeout>>javascriptContentOn: aStream
> >  aStream nextPutAll: 'setTimeout(function(){'.
> >  super javascriptContentOn: aStream.
> >  aStream
> >    nextPutAll: '},';
> >    javascript: self duration;
> >    nextPut: $)
> >
> > So in theory it should do the same thing.
> >
> > Did you try my attached example replacing the #setTimeout: call by the
> > #timeout: equivalent?
>
>         Yes, don't works
> >
> > Are you replacing the right DOM element in #scriptBannerUpdateOn: ?
>
>         Yes.  With interval:  is right update   ( therefore the reference is correct )
>
>
>
>         But which libraries should I add when register the application?
>
>         I register it with:
>
>                 app := WAAdmin register: self asApplicationAt: 'recursiveTimeout'.
>
>                 app addLibrary: JQDevelopmentLibrary
>
>         it's right?
>
>         Thanks,
>
>                 Dario
>
> > Regards,
> >
> > Esteban A. Maringolo
> >
> > El mié., 10 abr. 2019 a las 12:36, [hidden email]
> > (<[hidden email]>) escribió:
> >>
> >> Ciao,
> >>
> >>
> >>> Shouldn't your script have two < instead of one?  Like this:
> >>
> >>        it's an error in the email.
> >>
> >>        The code is right,
> >>
> >>                but with                 timeout:           the banner is not update.
> >>
> >>                with             interval:      it is update.
> >>
> >>        considerations ?
> >>
> >>        Thanks,
> >>
> >>                Dario
> >>
> >>>
> >>> scriptUpdaterOn: aJSScript
> >>>                 aJSScript <<
> >>>                        ((aJSScript jQuery ajax
> >>>                         script: [ :s |
> >>>                                       self shouldUpdate ifTrue: [ self
> >>> scriptBannerUpdateOn: s ].
> >>>                         ]) timeout: 1 minute)
> >>>
> >>>
> >>>
> >>>
> >>> [hidden email] wrote
> >>>> Ciao,
> >>>>
> >>>>> But using interval() is wrong. You're creating one new interval on every
> >>>>> call! And it doesn't have to be recursive.
> >>>>>
> >>>>> Maybe instead of #setInterval: it is #interval: in your image.
> >>>>
> >>>>     You mean      timeout:
> >>>>
> >>>>     But with:
> >>>>
> >>>>
> >>>>             scriptUpdaterOn: aJSScript
> >>>>                aJSScript <
> >>>>                        ((aJSScript jQuery ajax
> >>>>                         script: [ :s |
> >>>>                                       self shouldUpdate ifTrue: [ self
> >>>> scriptBannerUpdateOn: s ].
> >>>>                        ]) timeout: 1 minute)
> >>>>
> >>>>             i don't have any updating.
> >>>>
> >>>>     With:   scriptUpdaterOn: aJSScript
> >>>>                             aJSScript <
> >>>>                              ((aJSScript jQuery ajax
> >>>>                                       script: [ :s |
> >>>>                                             self shouldUpdate ifTrue: [ self
> >>>> scriptBannerUpdateOn: s ].
> >>>>                                             self scriptUpdaterOn: s
> >>>>                        ]) timeout: 1 minute)
> >>>>
> >>>>     i have strange behavior.
> >>>>
> >>>>     The browser application go to 50% of CPU.
> >>>>
> >>>>     Thanks,
> >>>>
> >>>>             Dario
> >>>>
> >>>>>
> >>>>> Regards,
> >>>>>
> >>>>> El mar., 9 de abr. de 2019 11:30,
> >>>
> >>>> dtrussardi@
> >>>
> >>>> &lt;
> >>>
> >>>> dtrussardi@
> >>>
> >>>> &gt; escribió:
> >>>>> Ciao,
> >>>>>
> >>>>>       thanks.
> >>>>>
> >>>>>> El lun., 8 abr. 2019 a las 7:48,
> >>>
> >>>> dtrussardi@
> >>>
> >>>>>> (&lt;
> >>>
> >>>> dtrussardi@
> >>>
> >>>> &gt;) escribió:
> >>>>>>
> >>>>>>>      In my case i haven't any user actions on the client.
> >>>>>>>      The client display some data with dynamic banner ( marquee tag
> >>>>> )
> >>>>>>>      and i need to update it only when the data to display change
> >>>>> from the server.
> >>>>>>>      When the data on the server relative to an banner change i need
> >>>>> to force the clients banners update.
> >>>>>>>      it seems to me that your initial solution may be fine.
> >>>>>>>
> >>>>>>>      What do you think?
> >>>>>>
> >>>>>> Too complex for such a simple task.
> >>>>>>
> >>>>>> Is the
> >>>> <marquee>
> >>>> tag still a thing? I though it dissapeared when
> >>>>>> Geocities closed. :)
> >>>>>>
> >>>>>> See below my suggestion.
> >>>>>>
> >>>>>>
> >>>>>>>      Another solution could be to manage an client ajax request with
> >>>>> a specific interval
> >>>>>>>      but  update the relative  banner div  only if the related data
> >>>>> received from the server changed.
> >>>>>>>              ( But how i can manage it?
> >>>>>>>               Can i not reply to an client ajax request
> >>>>>>>                      or respond to doing nothing and continue to
> >>>>> view the current status )
> >>>>>>
> >>>>>> You can have a recursive call to setInterval() that returns a script
> >>>>>> (javascript) that updates the mentioned banner, and if no update is
> >>>>>> necessary you do nothing. Doing it once per minute is nothing for the
> >>>>>> server, since it's a simple AJAX call, which if nothing needs
> >>>>>> updating, is fast to answer.
> >>>>>>
> >>>>>> These are the key parts:
> >>>>>>
> >>>>>> renderContentOn: html
> >>>>>> self renderBannerOn: html.
> >>>>>> html script: (html jQuery script: [ :script | self scriptUpdaterOn:
> >>>>> script ])
> >>>>>>
> >>>>>> scriptUpdaterOn: aJSScript
> >>>>>> aJSScript <<
> >>>>>>  ((aJSScript jQuery ajax
> >>>>>>    script: [ :s |
> >>>>>>      self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
> >>>>>>      self scriptUpdaterOn: s ]) setTimeout: 1 minute)
> >>>>>
> >>>>>       The setTimeout is not implemented in my system.
> >>>>>
> >>>>>       With    timeout:    i have some   problematic.
> >>>>>
> >>>>>       I change the             scriptUpdaterOn: aJSScript     to:
> >>>>>
> >>>>>       scriptUpdaterOn: aJSScript
> >>>>>               aJSScript <
> >>>>>                        ((aJSScript jQuery ajax
> >>>>>                         script: [ :s |
> >>>>>                                       self shouldUpdate ifTrue: [ self
> >>>>> scriptBannerUpdateOn: s ].
> >>>>>                       ]) interval: 1 minute)
> >>>>>
> >>>>>       It works very well relatively to my current needs.
> >>>>>
> >>>>>       Dario
> >>>>>
> >>>>>>
> >>>>>> scriptBannerUpdateOn: s
> >>>>>> s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn:
> >>>>> h ])
> >>>>>>
> >>>>>> Attached to this mails goes a working example of this.
> >>>>>>
> >>>>>> In #scriptBannerUpdateOn: I would put all the logic, even by replacing
> >>>>>> the whole component as a whole (sometimes the best compromise) or
> >>>>>> indidividual elements within it).
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> Regards,
> >>>>>>
> >>>>>> Esteban A. Maringolo
> >>>>>>
> >>>> <EAMRecursiveTimeout.st>
> >>>> _______________________________________________
> >>>>>> seaside mailing list
> >>>>>>
> >>>
> >>>> seaside@.squeakfoundation
> >>>
> >>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>>>>
> >>>>> _______________________________________________
> >>>>> seaside mailing list
> >>>>>
> >>>
> >>>> seaside@.squeakfoundation
> >>>
> >>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>>>> _______________________________________________
> >>>>> seaside mailing list
> >>>>>
> >>>
> >>>> seaside@.squeakfoundation
> >>>
> >>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> seaside mailing list
> >>>
> >>>> seaside@.squeakfoundation
> >>>
> >>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> Sent from: http://forum.world.st/Seaside-General-f86180.html
> >>> _______________________________________________
> >>> seaside mailing list
> >>> [hidden email]
> >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>
> >> _______________________________________________
> >> seaside mailing list
> >> [hidden email]
> >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> > _______________________________________________
> > seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous update from web server

dtrussardi@tiscali.it
Ciao Esteban,

thanks for your support.

The library is fine and the JQDevelopmentLibrary is just for the
replacement, the setTimeout() and interval() are part of the built-in
functions in all browsers and comes in the Javascript package of
Seaside itself.
OK
.

Can you share the code you're using? Is it exactly the same example I
sent a few mails back?
I do some test with Seaside 3.3.

i use this code:

scriptUpdaterOn: aJSScript
 aJSScript <<
    ((aJSScript jQuery ajax
     script: [ :s |
        self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
        self scriptUpdaterOn: s ]) setTimeout: 1 minute)

And all works well.

if I use the same code ( changing only  setTimeout   to  timeout: )

with Seaside 3.2.2   it happens  that the browser application loads the CPU of 50%.

and this complicates the situation.

If everything is clear to you and matches how it should work, 

for now i use interval: in Seaside 3.2.2 

and then update everything to setTimeout: when I bring the code into Seaside 3.3

Thank you so much,

Dario

P.S.  is it not clear to me why  scriptUpdaterOn: aJSScript it calls itself?



Which version of Seaside are you using?

       I using the Seaside 3.2.2   on Pharo 7.0-64-1262


I can see that #timeout: is the deprecated implementation of the
#setTimeout: method of latest Seaside releases, and it instantiates a
JSTimeout object whose #javascriptContentOn: is as follows:

       The following code is identical

JSTimeout>>javascriptContentOn: aStream
aStream nextPutAll: 'setTimeout(function(){'.
super javascriptContentOn: aStream.
aStream
  nextPutAll: '},';
  javascript: self duration;
  nextPut: $)

So in theory it should do the same thing.

Did you try my attached example replacing the #setTimeout: call by the
#timeout: equivalent?

       Yes, don't works

Are you replacing the right DOM element in #scriptBannerUpdateOn: ?

       Yes.  With interval:  is right update   ( therefore the reference is correct )



       But which libraries should I add when register the application?

       I register it with:

               app := WAAdmin register: self asApplicationAt: 'recursiveTimeout'.

               app addLibrary: JQDevelopmentLibrary

       it's right?

       Thanks,

               Dario

Regards,

Esteban A. Maringolo

El mié., 10 abr. 2019 a las 12:36, [hidden email]
(<[hidden email]>) escribió:

Ciao,


Shouldn't your script have two < instead of one?  Like this:

      it's an error in the email.

      The code is right,

              but with                 timeout:           the banner is not update.

              with             interval:      it is update.

      considerations ?

      Thanks,

              Dario


scriptUpdaterOn: aJSScript
               aJSScript <<
                      ((aJSScript jQuery ajax
                       script: [ :s |
                                     self shouldUpdate ifTrue: [ self
scriptBannerUpdateOn: s ].
                       ]) timeout: 1 minute)




[hidden email] wrote
Ciao,

But using interval() is wrong. You're creating one new interval on every
call! And it doesn't have to be recursive.

Maybe instead of #setInterval: it is #interval: in your image.

   You mean      timeout:

   But with:


           scriptUpdaterOn: aJSScript
              aJSScript <
                      ((aJSScript jQuery ajax
                       script: [ :s |
                                     self shouldUpdate ifTrue: [ self
scriptBannerUpdateOn: s ].
                      ]) timeout: 1 minute)

           i don't have any updating.

   With:   scriptUpdaterOn: aJSScript
                           aJSScript <
                            ((aJSScript jQuery ajax
                                     script: [ :s |
                                           self shouldUpdate ifTrue: [ self
scriptBannerUpdateOn: s ].
                                           self scriptUpdaterOn: s
                      ]) timeout: 1 minute)

   i have strange behavior.

   The browser application go to 50% of CPU.

   Thanks,

           Dario


Regards,

El mar., 9 de abr. de 2019 11:30,

dtrussardi@

&lt;

dtrussardi@

&gt; escribió:
Ciao,

     thanks.

El lun., 8 abr. 2019 a las 7:48,

dtrussardi@

(&lt;

dtrussardi@

&gt;) escribió:

    In my case i haven't any user actions on the client.
    The client display some data with dynamic banner ( marquee tag
)
    and i need to update it only when the data to display change
from the server.
    When the data on the server relative to an banner change i need
to force the clients banners update.
    it seems to me that your initial solution may be fine.

    What do you think?

Too complex for such a simple task.

Is the
<marquee>
tag still a thing? I though it dissapeared when
Geocities closed. :)

See below my suggestion.


    Another solution could be to manage an client ajax request with
a specific interval
    but  update the relative  banner div  only if the related data
received from the server changed.
            ( But how i can manage it?
             Can i not reply to an client ajax request
                    or respond to doing nothing and continue to
view the current status )

You can have a recursive call to setInterval() that returns a script
(javascript) that updates the mentioned banner, and if no update is
necessary you do nothing. Doing it once per minute is nothing for the
server, since it's a simple AJAX call, which if nothing needs
updating, is fast to answer.

These are the key parts:

renderContentOn: html
self renderBannerOn: html.
html script: (html jQuery script: [ :script | self scriptUpdaterOn:
script ])

scriptUpdaterOn: aJSScript
aJSScript <<
((aJSScript jQuery ajax
  script: [ :s |
    self shouldUpdate ifTrue: [ self scriptBannerUpdateOn: s ].
    self scriptUpdaterOn: s ]) setTimeout: 1 minute)

     The setTimeout is not implemented in my system.

     With    timeout:    i have some   problematic.

     I change the             scriptUpdaterOn: aJSScript     to:

     scriptUpdaterOn: aJSScript
             aJSScript <
                      ((aJSScript jQuery ajax
                       script: [ :s |
                                     self shouldUpdate ifTrue: [ self
scriptBannerUpdateOn: s ].
                     ]) interval: 1 minute)

     It works very well relatively to my current needs.

     Dario


scriptBannerUpdateOn: s
s << ((s jQuery id: 'banner') replaceWith: [ :h | self renderBannerOn:
h ])

Attached to this mails goes a working example of this.

In #scriptBannerUpdateOn: I would put all the logic, even by replacing
the whole component as a whole (sometimes the best compromise) or
indidividual elements within it).



Regards,

Esteban A. Maringolo

<EAMRecursiveTimeout.st>
_______________________________________________
seaside mailing list


seaside@.squeakfoundation

http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list


seaside@.squeakfoundation

http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list


seaside@.squeakfoundation

http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list

seaside@.squeakfoundation

http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside





--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside