Call an RPC given a header and possibly a previously sent payload

        Args:
            header (bytearray): The RPC header we should call
320418
async def _call_rpc(self, header):
        

        length, _, cmd, feature, address = struct.unpack("<BBBBB", bytes(header))
        rpc_id = (feature << 8) | cmd

        payload = self.rpc_payload[:length]

        self._logger.debug("Calling RPC %d:%04X with %s", address, rpc_id, binascii.hexlify(payload))

        exception = None
        response = None

        try:
            response = await self.send_rpc(self.CLIENT_ID, str(self.device.iotile_id), address, rpc_id, bytes(payload), timeout=30.0)
        except VALID_RPC_EXCEPTIONS as err:
            exception = err
        except Exception as err:
            self._logger.exception("Error calling RPC %d:%04X", address, rpc_id)
            exception = err

        status, response = pack_rpc_response(response, exception)
        resp_header = struct.pack("<BBBB", status, 0, 0, len(response))

        await self._send_notification(self.ReceiveHeaderHandle, resp_header)

        if len(response) > 0:
            await self._send_notification(self.ReceivePayloadHandle, response)
1343639
def rpc_call(self, request, method=None, **payload):
        
        if not method or self.separator not in method:
            raise AssertionError("Wrong method name: {0}".format(method))

        resource_name, method = method.split(self.separator, 1)
        if resource_name not in self.api.resources:
            raise AssertionError("Unknown method " + method)

        data = QueryDict('', mutable=True)
        data.update(payload.get('data', dict()))
        data['callback'] = payload.get('callback') or request.GET.get(
            'callback') or request.GET.get('jsonp') or 'callback'
        for h, v in payload.get('headers', dict()).iteritems():
            request.META["HTTP_%s" % h.upper().replace('-', '_')] = v

        request.POST = request.PUT = request.GET = data
        delattr(request, '_request')
        request.method = method.upper()
        request.META['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
        params = payload.pop('params', dict())
        response = self.api.call(resource_name, request, **params)

        if not isinstance(response, SerializedHttpResponse):
            return response

        if response['Content-type'] in self._meta.emitters_dict:
            return HttpResponse(response.content, status=response.status_code)

        if response.status_code == 200:
            return response.response

        raise AssertionError(response.response)
1252236
def _process_method_frame(self, channel, payload):
        
        method_sig = unpack('>HH', payload[:4])
        args = AMQPReader(payload[4:])

        if method_sig in _CONTENT_METHODS:
            #
            # Save what we've got so far and wait for the content-header
            #
            self.partial_messages[channel] = _PartialMessage(method_sig, args)
            self.expected_types[channel] = 2
        else:
            self.queue.put((channel, method_sig, args, None))
116306
def send_headers(self):
        
        self.events.sync_emit('headers')
        self._set_default_headers()
        header_str = self.status_line + self.EOL + str(self.headers)
        self.stream.write(header_str.encode())
        self.events.sync_emit('after_headers')
7603
def on_headers(self, response, exc=None):
        ''''''

        if response.status_code == 101:
            connection = response.connection
            request = response.request
            handler = request.websocket_handler
            if not handler:
                handler = WS()
            parser = request.client.frame_parser(kind=1)
            consumer = partial(WebSocketClient.create,
                               response, handler, parser)
            connection.upgrade(consumer)
            response.event('post_request').fire()
            websocket = connection.current_consumer()
            response.request_again = lambda r: websocket
810818
def call(self, method, *args):
        

        payload = self.build_payload(method, args)
        logging.debug('* Client will send payload: {}'.format(payload))
        self.send(payload)

        res = self.receive()
        assert payload[2] == res['ref']
        return res['result'], res['error']
1279689
public static Message from_header(byte[] header)
	{
		if(header==null || header.length!=HEADER_SIZE)
			throw new PyroException("header data size mismatch");
		
		if(header[0]!='P'||header[1]!='Y'||header[2]!='R'||header[3]!='O') 
			throw new PyroException("invalid message");    		

		int version = ((header[4]&0xff) << 8)|(header[5]&0xff);
		if(version!=Config.PROTOCOL_VERSION)
			throw new PyroException("invalid protocol version: "+version);
		
		int msg_type = ((header[6]&0xff) << 8)|(header[7]&0xff);
		int flags = ((header[8]&0xff) << 8)|(header[9]&0xff);
		int seq = ((header[10]&0xff) << 8)|(header[11]&0xff);
		int data_size=header[12]&0xff;
		data_size<<=8;
		data_size|=header[13]&0xff;
		data_size<<=8;
		data_size|=header[14]&0xff;
		data_size<<=8;
		data_size|=header[15]&0xff;
		int serializer_id = ((header[16]&0xff) << 8)|(header[17]&0xff);
		int annotations_size = ((header[18]&0xff) <<8)|(header[19]&0xff);
		// byte 20 and 21 are reserved.
		int checksum = ((header[22]&0xff) << 8)|(header[23]&0xff);
		int actual_checksum = (msg_type+version+data_size+annotations_size+flags+serializer_id+seq+CHECKSUM_MAGIC)&0xffff;
		if(checksum!=actual_checksum)
			throw new PyroException("header checksum mismatch");
		
		Message msg = new Message(msg_type, serializer_id, flags, seq);
		msg.data_size = data_size;
		msg.annotations_size = annotations_size;
		return msg;
	}
185811
def header_from_raw_header_data(cls, raw_header):
        
        try:
            header = MessageHeader(*cls.header_struct.unpack(raw_header))
        except struct.error:
            raise Exception("Invalid message header received")
        return header
1129141
def __send_message_recv_reply(self, packed_message):
        
        payload = io.BytesIO()
        try:
            with self._socket_lock:
                self._socket.sendall(packed_message)

                # Read first message header
                raw_header = self._socket.recv(32)
                header = ReplyMessage.header_from_raw_header_data(raw_header)

                # from pyhdb.lib.stringlib import allhexlify
                # print 'Raw msg header:', allhexlify(raw_header)
                msg = 'Message header (32 bytes): sessionid: %d, packetcount: %d, length: %d, size: %d, noofsegm: %d'
                debug(msg, *(header[:5]))

                # Receive complete message payload
                while payload.tell() < header.payload_length:
                    _payload = self._socket.recv(header.payload_length - payload.tell())
                    if not _payload:
                        break   # jump out without any warning??
                    payload.write(_payload)

                debug('Read %d bytes payload from socket', payload.tell())

                # Keep session id of connection up to date
                if self.session_id != header.session_id:
                    self.session_id = header.session_id
                    self.packet_count = -1
        except socket.timeout:
            raise ConnectionTimedOutError()
        except (IOError, OSError) as error:
            raise OperationalError("Lost connection to HANA server (%r)" % error)

        payload.seek(0)  # set pointer position to beginning of buffer
        return ReplyMessage.unpack_reply(header, payload)
43741
def create_rpc_request_header(self):
        ''''''
        rpcheader = RpcRequestHeaderProto()
        rpcheader.rpcKind = 2  # rpcheaderproto.RpcKindProto.Value('RPC_PROTOCOL_BUFFER')
        rpcheader.rpcOp = 0  # rpcheaderproto.RpcPayloadOperationProto.Value('RPC_FINAL_PACKET')
        rpcheader.callId = self.call_id
        rpcheader.retryCount = -1
        rpcheader.clientId = self.client_id[0:16]

        if self.call_id == -3:
            self.call_id = 0
        else:
            self.call_id += 1

        # Serialize delimited
        s_rpcHeader = rpcheader.SerializeToString()
        log_protobuf_message("RpcRequestHeaderProto (len: %d)" % (len(s_rpcHeader)), rpcheader)
        return s_rpcHeader
697321
async def do_api_call(self):
        """"""
        self.pyvlx.connection.register_frame_received_cb(
            self.response_rec_callback)
        await self.send_frame()
        await self.start_timeout()
        await self.response_received_or_timeout.wait()
        await self.stop_timeout()
        self.pyvlx.connection.unregister_frame_received_cb(self.response_rec_callback)
616376
def call(self, command, *args):
        
        return self.rpc.call(str(command), *args)
246560
def RPC(self, url, opname, obj, replytype=None, **kw):
        '''
        '''
        self.Send(url, opname, obj, **kw)
        return self.Receive(replytype, **kw)
109089
def writeHeader(self, msg):
		

		header = bytearray([self.protocol_version]) #protocol version 1.0
		header.extend(struct.pack('<H', len(msg)))

		msg = header + msg

		return msg
53430
void sendHeaderAndCounterNameAndRead(Channel channel) {
      ByteBuf buf = getHeaderAndCounterNameBufferAndRead(channel, 0);
      channel.writeAndFlush(buf);
   }
592000
async def send(self, parameters: RTCRtpSendParameters):
        
        if not self.__started:
            self.__cname = parameters.rtcp.cname
            self.__mid = parameters.muxId

            # make note of the RTP header extension IDs
            self.__transport._register_rtp_sender(self, parameters)
            self.__rtp_header_extensions_map.configure(parameters)

            # make note of RTX payload type
            for codec in parameters.codecs:
                if is_rtx(codec) and codec.parameters['apt'] == parameters.codecs[0].payloadType:
                    self.__rtx_payload_type = codec.payloadType
                    break

            self.__rtp_task = asyncio.ensure_future(self._run_rtp(parameters.codecs[0]))
            self.__rtcp_task = asyncio.ensure_future(self._run_rtcp())
            self.__started = True
513425
def call_signature(request_method)
      desc = rpc_desc(request_method)
      desc&.name ? desc.name.to_s.underscore.to_sym : nil
    end