Index: jive/share/jive/slim/SlimServer.lua =================================================================== --- jive/share/jive/slim/SlimServer.lua (revision 1998) +++ jive/share/jive/slim/SlimServer.lua (working copy) @@ -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 @@ -362,6 +365,8 @@ function disconnect(self) log:info(self, ":disconnect()") + self.connecting = false + self.artworkPool:close() self.comet:disconnect() end @@ -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,16 +425,34 @@ =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.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() end Index: jive/share/jive/slim/SlimServers.lua =================================================================== --- jive/share/jive/slim/SlimServers.lua (revision 1998) +++ jive/share/jive/slim/SlimServers.lua (working copy) @@ -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") Index: jive/share/jive/net/Comet.lua =================================================================== --- jive/share/jive/net/Comet.lua (revision 1998) +++ jive/share/jive/net/Comet.lua (working copy) @@ -174,6 +174,8 @@ function connect(self) log:debug(self, ": connect state=", self.state) + self.isactive = true + if self.state == CONNECTING or self.state == CONNECTED then -- Already connecting/connected return @@ -184,7 +186,6 @@ _state(self, UNCONNECTED) end - self.isactive = true _handshake(self) end @@ -192,6 +193,8 @@ function disconnect(self) log:debug(self, ": disconnect state=", self.state) + self.isactive = false + if self.state == UNCONNECTED or self.state == UNCONNECTING then -- Already disconnecting/unconnected return @@ -203,7 +206,6 @@ return end - self.isactive = false _disconnect(self) end