Prepare this device to receive RPCs
425413
def _enable_rpcs(self, conn, services, timeout=1.0):
        

        #FIXME: Check for characteristic existence in a try/catch and return failure if not found

        success, result = self._set_notification(conn, services[TileBusService]['characteristics'][TileBusReceiveHeaderCharacteristic], True, timeout)
        if not success:
            return success, result

        return self._set_notification(conn, services[TileBusService]['characteristics'][TileBusReceivePayloadCharacteristic], True, timeout)
576251
def connect(request, _unused_call)
      logger.debug("RPC Connect: #{request.inspect}")

      socket = build_socket(env: rack_env(request))

      connection = factory.call(socket)

      connection.handle_open

      if socket.closed?
        AnyCable::ConnectionResponse.new(status: AnyCable::Status::FAILURE)
      else
        AnyCable::ConnectionResponse.new(
          status: AnyCable::Status::SUCCESS,
          identifiers: connection.identifiers_json,
          transmissions: socket.transmissions
        )
      end
    rescue StandardError => exp
      notify_exception(exp, :connect, request)

      AnyCable::ConnectionResponse.new(
        status: AnyCable::Status::ERROR,
        error_msg: exp.message
      )
    end
1211221
def step1(self, pin):
        """"""
        context = SRPContext(
            'Pair-Setup', str(pin),
            prime=constants.PRIME_3072,
            generator=constants.PRIME_3072_GEN,
            hash_func=hashlib.sha512)
        self._session = SRPClientSession(
            context, binascii.hexlify(self._auth_private).decode())
352928
def connect(self):
        """"""
        self._client = Telnet(self.hostname, self.port)
        self.closed = False
        query = {
            "MPRPC": self.VERSION,
            "AUTH": {
                "USERNAME": self.username,
                "PASSWORD": self.password
            }
        }
        queryb = self.encoder(query)
        if self.debug is True:
            print("send auth {}".format(queryb))
        self._client.write(queryb)
        self.remote_info = self._responsehandler()
571501
async def start(self):
        """"""
        if self.connection.connected:
            return

        await self.connection.connect()

        # In case credentials have been given externally (i.e. not by pairing
        # with a device), then use that client id
        if self.service.device_credentials:
            self.srp.pairing_id = Credentials.parse(
                self.service.device_credentials).client_id

        # The first message must always be DEVICE_INFORMATION, otherwise the
        # device will not respond with anything
        msg = messages.device_information(
            'pyatv', self.srp.pairing_id.decode())
        await self.send_and_receive(msg)
        self._initial_message_sent = True

        # This should be the first message sent after encryption has
        # been enabled
        await self.send(messages.set_ready_state())

        async def _wait_for_updates(_, semaphore):
            # Use a counter here whenever more than one message is expected
            semaphore.release()

        # Wait for some stuff to arrive before returning
        semaphore = asyncio.Semaphore(value=0, loop=self.loop)
        self.add_listener(_wait_for_updates,
                          protobuf.SET_STATE_MESSAGE,
                          data=semaphore,
                          one_shot=True)

        # Subscribe to updates at this stage
        await self.send(messages.client_updates_config())
        await self.send(messages.wake_device())

        try:
            await asyncio.wait_for(
                semaphore.acquire(), 1, loop=self.loop)
        except asyncio.TimeoutError:
            # This is not an issue itself, but I should do something better.
            # Basically this gives the device about one second to respond with
            # some metadata before continuing.
            pass
869826
async def rpc_message(self, request, message):
        ''''''
        await self.pubsub.publish(self.channel, message)
        return 'OK'
713235
def rpc(ctx, call, arguments, api):
    
    try:
        data = list(eval(d) for d in arguments)
    except:
        data = arguments
    ret = getattr(ctx.bitshares.rpc, call)(*data, api=api)
    print_dict(ret)
1351601
async def Resolved(self, retry, unit_name):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Client',
                   request='Resolved',
                   version=1,
                   params=_params)
        _params['retry'] = retry
        _params['unit-name'] = unit_name
        reply = await self.rpc(msg)
        return reply
494919
def setup_client_rpc(self):
        """"""
        # Setup RPC client.
        self.clnt = rpc.DfaRpcClient(self._url, constants.DFA_SERVER_QUEUE,
                                     exchange=constants.DFA_EXCHANGE)
506592
function prepareData(response, rootUrl, data) {
  if(data.devices) {
    var devices = data.devices;
    for(var device in devices) {
      devices[device].href = rootUrl + '/whereis/transmitter/' + device;
      var radioDecodings = devices[device].radioDecodings;
      for(var cDecoding = 0; cDecoding < radioDecodings.length; cDecoding++) {
        var radioDecoder = radioDecodings[cDecoding].identifier.value;
        radioDecodings[cDecoding].href = rootUrl + '/whatat/receiver/' +
                                         radioDecoder;
      }
    }
    response.devices = devices;
  }
}
246560
def RPC(self, url, opname, obj, replytype=None, **kw):
        '''
        '''
        self.Send(url, opname, obj, **kw)
        return self.Receive(replytype, **kw)
1057706
def SETUP(self):
        """"""
        message = "SETUP " + self.session.control_url + " RTSP/1.0\r\n"
        message += self.sequence
        message += self.authentication
        message += self.user_agent
        message += self.transport
        message += '\r\n'
        return message
473857
function createClient() {
	rpc.emit('createClient', 'test', {
		nick : 'simpleircbot',
		user : 'testuser',
		server : 'localhost',
		realname: 'realbot',
		port: 6667,
		secure: false,
		retryCount: 2,
		retryWait: 3000
	});
}
1092139
def connect(self, addr):
        """"""
        if _debug: DeviceToDeviceClientService._debug("connect %r", addr)

        # make a connection
        conn = ConnectionState(addr)
        self.multiplexer.connections[addr] = conn

        # associate with this service, but it is not connected until the ack comes back
        conn.service = self

        # keep a list of pending NPDU objects until the ack comes back
        conn.pendingNPDU = []

        # build a service request
        request = ServiceRequest(DEVICE_TO_DEVICE_SERVICE_ID)
        request.pduDestination = addr

        # send it
        self.service_request(request)

        # return the connection object
        return conn
1278194
async def send_rpc(self, conn_id, address, rpc_id, payload, timeout):
        

        resp = await self._execute(self._adapter.send_rpc_sync, conn_id, address, rpc_id, payload, timeout)
        _raise_error(conn_id, 'send_rpc', resp)

        status = resp.get('status')
        payload = resp.get('payload')

        # This will raise an exception if needed based on status
        return unpack_rpc_response(status, payload, rpc_id, address)
1256100
def _prepare_fetch(self, request: Request, response: Response):
        '''
        '''
        self._request = request
        self._response = response

        yield from self._init_stream()

        connection_closed = self._control_connection.closed()

        if connection_closed:
            self._login_table.pop(self._control_connection, None)
            yield from self._control_stream.reconnect()

        request.address = self._control_connection.address

        connection_reused = not connection_closed
        self.event_dispatcher.notify(self.Event.begin_control, request, connection_reused=connection_reused)

        if connection_closed:
            yield from self._commander.read_welcome_message()

        yield from self._log_in()

        self._response.request = request
1045013
def process_rpc(self, rpc):
        """"""
        p = "/nc:rpc/" + self.qname(rpc)
        tmpl = self.xsl_template(p)
        inp = rpc.search_one("input")
        if inp is not None:
            ct = self.xsl_calltemplate("rpc-input", tmpl)
            self.xsl_withparam("nsid", rpc.i_module.i_modulename + ":", ct)
            self.process_children(inp, p, 2)
        outp = rpc.search_one("output")
        if outp is not None:
            self.process_children(outp, "/nc:rpc-reply", 1)