More information on this. I changed my basicrouter.py command to close the client, and that seems to work. When the client connects I record its sessionid/session, then I created a message called adm.session.kill(sessionid) which recalls the session for the client and runs:
ses._transport.close()
This definitely closes the connection.
I tried to send information to the client about the close, I tried:
ses._transport.close(reason='killed')
close reason without close code
ses._transport.close(reason='killed', code=3000)
and I get
invalid type <type 'str'> for close reason
dug through the code a bit, and I see that 'six' is wanted for the reason type:
if type(reason) != six.text_type:
raise Exception("invalid type %s for close reason" % type(reason))
So I changed that:
import six
ses._transport.close(reason=six.u('killed'), code=3000)
So that works, when I look at the verbose output of the session that was just killed:
onLeave: CloseDetails(reason = None, message = 'None'')
Which was produced by this:
def onLeave(self, details):
print("onLeave: {}".format(details))
Which leads me to my question about sendClose(). I think I got it to work, but, I could have very well been calling the wrong thing. Is this the right way to kill a session? If so is it useful to use a reason and a code? Finally, it doesn't matter what I put after the onLeave print statement, I cannot get the client to exit. I've tried reactor.stop(), self.disconnect(), self.close(), etc.. Nothing seems to work. I tried sys.exit(42), that didn't work. os._exit(42) worked, but, that's over the top.
-g