def callback(message): """ Callback to be invoked when a response to the START_SESSION request is received. """ Sessions.remove(session) console.write(message.SerializeToString())
def sessionList(self, message): """ Called by the runtime on receipt of a listing of active sessions from the Agent. The Sessions collection is updated with the most recent information. """ for session in message.system_response.sessions: Sessions.add_session(session.session_id, self, None)
def callback(message): """ Callback to be invoked when a response to the START_SESSION request is received. """ Sessions.add_session(message.system_response.session_id, self, console) console.write(message.SerializeToString())
def stopSession(self, message): """ Invoked when a Console wishes to terminate an established Session. """ session = Sessions.get(message.system_request.session_id) if session is not None: return session.device.stopSession(self.connection, session, message) else: return SystemResponseFactory\ .error(Message.SystemResponse.SESSION_ID, "unknown session")\ .inReplyTo(message)\ .build()
def handle(self, message): """ handle() is passed messages for the ReflectionResponseForwarder to forward. """ if message.type != Message.REFLECTION_RESPONSE: raise Exception("is not a REFLECTION_RESPONSE") if not message.HasField('reflection_response'): raise Exception("does not contain a REFLECTION_RESPONSE") session = Sessions.get(message.reflection_response.session_id) if session is not None: session.console.write(message.SerializeToString()) else: print "no session:", message.reflection_response.session_id
def handle(self, message): """ handle() is passed messages for the ReflectionRequestForwarder to forward. """ if message.type != Message.REFLECTION_REQUEST: raise Exception("is not a REFLECTION_REQUEST") if not message.HasField('reflection_request'): raise Exception("does not contain a REFLECTION_REQUEST") session = Sessions.get(message.reflection_request.session_id) if session is not None: try: session.device.write(message.SerializeToString()) except DeviceGoneAway as e: session.console.write(ReflectionResponseFactory.fatal(str(e)).inReplyTo(message).build()) session.console.transport.loseConnection() else: print "no session:", message.reflection_request.session_id
def handle(self, message): """ handle() is passed messages for the ReflectionRequestForwarder to forward. """ if message.type != Message.REFLECTION_REQUEST: raise Exception("is not a REFLECTION_REQUEST") if not message.HasField('reflection_request'): raise Exception("does not contain a REFLECTION_REQUEST") session = Sessions.get(message.reflection_request.session_id) if session is not None: try: session.device.write(message.SerializeToString()) except DeviceGoneAway as e: session.console.write( ReflectionResponseFactory.fatal( str(e)).inReplyTo(message).build()) session.console.transport.loseConnection() else: print "no session:", message.reflection_request.session_id