Commit 1740e0c8 authored by Vincent Pelletier's avatar Vincent Pelletier

Merge method into its only caller.

Also, don't wait for client disconnection.
Also, factorise packet creation.
parent cf8ec8c1
...@@ -198,25 +198,6 @@ class Application(object): ...@@ -198,25 +198,6 @@ class Application(object):
self.primary = self.primary is None self.primary = self.primary is None
break break
def _announcePrimary(self):
"""
Broadcast the announce that I'm the primary
"""
# I am the primary.
neo.lib.logging.debug('I am the primary, sending an announcement')
for conn in self.em.getClientList():
conn.notify(Packets.AnnouncePrimary())
conn.abort()
t = time()
while self.em.getClientList():
self.em.poll(1)
if t + 10 < time():
for conn in self.em.getClientList():
conn.close()
break
def broadcastNodesInformation(self, node_list): def broadcastNodesInformation(self, node_list):
""" """
Broadcast changes for a set a nodes Broadcast changes for a set a nodes
...@@ -298,10 +279,10 @@ class Application(object): ...@@ -298,10 +279,10 @@ class Application(object):
def playPrimaryRole(self): def playPrimaryRole(self):
neo.lib.logging.info( neo.lib.logging.info(
'play the primary role with %r', self.listening_conn) 'play the primary role with %r', self.listening_conn)
packet = Packets.AnnouncePrimary()
# i'm the primary, send the announcement for conn in self.em.getClientList():
self._announcePrimary() conn.notify(packet)
# all incoming connections identify through this handler conn.abort()
self.listening_conn.setHandler( self.listening_conn.setHandler(
identification.IdentificationHandler(self)) identification.IdentificationHandler(self))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment