Author: titmuss
Date: Fri Feb 22 13:20:37 2008
New Revision: 2002

URL: http://svn.slimdevices.com?rev=2002&root=Jive&view=rev
Log:
Bug: 7240
Description:
Use the SqueezeCenter server name as the unique key, not the ip:port value. 
This allows jive to reconnect to the server if 
the ip value changes.
Create new Comet and Artwork connections when jive detects the SqueezeCenter 
ip:port values have changed.
Start UDP discovery when the current server is disconnected, this allows jive 
to rediscover the SqueezeCenter if it's IP 
address changes.


Modified:
    trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua
    trunk/jive/src/pkg/jive/share/jive/slim/SlimServers.lua

Modified: trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua?rev=2002&root=Jive&r1=2001&r2=2002&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/slim/SlimServer.lua Fri Feb 22 13:20:37 
2008
@@ -248,6 +248,7 @@
 
                -- are we connected to the server?
                active = false,
+               connecting = false,
 
                -- queue of artwork to fetch
                artworkFetchQueue = {},
@@ -354,6 +355,8 @@
 function connect(self)
        log:info(self, ":connect()")
 
+       self.connecting = true
+
        -- artwork pool connects on demand
        self.comet:connect()
 end
@@ -361,6 +364,8 @@
 
 function disconnect(self)
        log:info(self, ":disconnect()")
+
+       self.connecting = false
 
        self.artworkPool:close()
        self.comet:disconnect()
@@ -405,7 +410,8 @@
 =cut
 --]]
 function idFor(self, ip, port, name)
-       return tostring(ip) .. ":" .. tostring(port)
+       -- XXXX remove this function and just use SC name
+       return name
 end
 
 
@@ -419,14 +425,33 @@
 
 =cut
 --]]
-function updateFromUdp(self, name)
+function updateFromUdp(self, ip, port, name)
        log:debug(self, ":updateFromUdp()")
 
        -- update the name in all cases
        if self.name ~= name then
-       
                log:info(self, ": Renamed to ", name)
                self.name = name
+       end
+
+       if self.plumbing.ip ~= ip or self.plumbing.port ~= port then
+               log:info(self, ": IP Address changed to ", ip , ":", port, " 
connecting=", self.connecting)
+
+               local connecting = self.connecting
+
+               -- close old comet connection
+               self:disconnect()
+
+               -- open new comet connection
+               self.plumbing.ip = ip
+               self.plumbing.port = port
+               self.artworkPool = HttpPool(self.jnt, name, ip, port, 2, 1, 
Task.PRIORITY_LOW)
+               self.comet = Comet(self.jnt, ip, port, '/cometd', name)
+
+               -- reconnect, if we were already connected
+               if connecting then
+                       self:connect()
+               end
        end
 
        self.plumbing.lastSeen = Framework:getTicks()

Modified: trunk/jive/src/pkg/jive/share/jive/slim/SlimServers.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/slim/SlimServers.lua?rev=2002&root=Jive&r1=2001&r2=2002&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/slim/SlimServers.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/slim/SlimServers.lua Fri Feb 22 13:20:37 
2008
@@ -94,7 +94,7 @@
        
        -- update the server with the name info, might have changed
        -- also keeps track of the last time we've seen the server for deletion
-       self._servers[ss_id]:updateFromUdp(ss_name)
+       self._servers[ss_id]:updateFromUdp(ss_ip, ss_port, ss_name)
 end
 
 
@@ -462,6 +462,19 @@
 end
 
 
+-- restart discovery if the current slimserver disconnects
+function notify_serverDisconnected(self, slimserver)
+       if not self.currentPlayer or self.currentPlayer:getSlimServer() ~= 
slimserver then
+               return
+       end
+
+       -- start discovery, use a timer to make sure we don't loop
+       -- back into the Comet class while handling the event.
+       self.discoverState = 'discover'
+       self.discoverTimer:restart(1)
+end
+
+
 -- restart discovery on new network
 function notify_networkConnected(self)
        log:info("network connected")

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to