def command(self, request_type, uri, payload):
        """Build and send a command."""
        self.command_count += 1

        if payload is None:
            payload = {}

        message = {
            'id': "{}_{}".format(type, self.command_count),
            'type': request_type,
            'uri': "ssap://{}".format(uri),
            'payload': payload,
        }

        self.last_response = None

        try:
            loop = asyncio.new_event_loop()
            asyncio.set_event_loop(loop)
            loop.run_until_complete(asyncio.wait_for(self._command(message), self.timeout_connect, loop=loop))
        finally:
            loop.close()
def command ( self , request_type , uri , payload ) : self . command_count += 1 if payload is None : payload = { } message = { 'id' : "{}_{}" . format ( type , self . command_count ) , 'type' : request_type , 'uri' : "ssap://{}" . format ( uri ) , 'payload' : payload , } self . last_response = None try : loop = asyncio . new_event_loop ( ) asyncio . set_event_loop ( loop ) loop . run_until_complete ( asyncio . wait_for ( self . _command ( message ) , self . timeout_connect , loop = loop ) ) finally : loop . close ( )
Build and send a command.