2011/8/11 Martin Hamant <[email protected]>:
> Hi all !!

Hi!

> For now my app updates metadata via a telnet command like
> xxx.insert title="my title"
>
> the title string is retrieved from an url by my app.
>
> It works fine BUT, the code to handle this is something heavy...
> (thread, etc) and more, if the app close, metadata are not updated
> anymore. And my aim was just to control liquidsoap features, somehow
> based on "client/server".
> I mean, if I start to implement things that liquidsoap can do itself
> internaly, it doesn't make sense...
> As I am pretty sure that liquidsoap can handle this, I am asking for
> advices :)
>
> I see there is a http.get(), with which I can retrieve the content of a
> remote file.
> How do I implement the periodical "go grab the content, and if it has
> changed then updated it, else; keep the previous". ?

add_timeout + http.get + insert_metadata :-)
Something like this:

# A source
s = (...)

# Attach metadata insertion hooks
x = insert_metadata(s)
insert = fst(x)
s = snd(x)

# A reference to the latest metadata
latest_meta = ref []

# A function to update metadata
def update_meta() =
  data = http.get(...)
  m = (..parse data here..)
  if m != !latest_meta then
    latest_meta := m
    insert_metadata(m)
  end
  # Restart in 10. seconds
  10.
end

# Start polling now
add_timeout(0., update_meta)

I have not tested this code but I think it should be close to working
and also close to what you describe :-)

Romain

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to