[Twisted-Python] Sending a "good-bye message" before closing a connection

Itamar Turner-Trauring itamar at itamarst.org
Fri Nov 18 06:31:18 MST 2011


On Fri, 2011-11-18 at 12:23 +0100, Albert Brandl wrote:

> But sometimes, the clients have to go offline. In this case, I'd like 
> them to send a message to the server that they will be gone for a
> while.
> When a client goes offline, the twistd daemon for handling the
> heartbeats
> is shut down.

Presumably there is a method somewhere that decides to close the
connection down:

   def timeToShutdown(self):
       self.transport.loseConnection()

So instead do:

   def timeToShutdown(self):
       self.transport.write(GOODBYE)
       self.transport.loseConnection()






More information about the Twisted-Python mailing list