// Receive will receive and match the specified packets out of order.
559151
func (f *Flow) Receive(pkts ...packet.Generic) *Flow {
	f.add(action{
		kind:    actionReceive,
		packets: pkts,
	})

	return f
}
964335
func (c *IPHAConn) receive() (*advertisement, error) {
	p, err := c.readPacket()
	if err != nil {
		switch err := err.(type) {
		case *net.OpError:
			// Ignore "protocol not available" ICMP messages. These occur in response to advertisements
			// sent from this node when it is master and the ha process on the peer is down.
			if errno, ok := err.Err.(syscall.Errno); ok {
				if errno == syscall.ENOPROTOOPT || errno == syscall.EPROTO {
					log.Infof("IPHAConn.receive: Ignoring ENOPROTOOPT/EPROTO")
					return nil, nil
				}
			}
		}
		return nil, err
	} else if len(p.payload) != vrrpAdvertSize {
		// Ignore
		return nil, nil
	}

	advert := &advertisement{}
	reader := bytes.NewReader(p.payload)
	if err := binary.Read(reader, binary.BigEndian, advert); err != nil {
		return nil, err
	}

	// Drop packets from ourselves.
	if p.src.Equal(c.laddr) {
		log.Warningf("IPHAConn.receive: Received packet from localhost (%v)", p.src)
		return nil, nil
	}

	// Drop packets that don't have a TTL/HOPLIMIT.
	if p.ttl != 255 {
		log.Warningf("IPHAConn.receive: Invalid TTL/HOPLIMIT %d from %v", p.ttl, p.src)
		return nil, nil
	}

	// Validate the VRRP checksum.
	chksum, err := checksum(advert, p.src, p.dst)
	if err != nil {
		log.Errorf("IPHAConn.receive: Failed to compute checksum from %v", p.src)
		return nil, nil
	}

	if chksum != 0 {
		log.Warningf("IPHAConn.receive: Invalid VRRP checksum (%x) from %v", advert.Checksum, p.src)
		return nil, nil
	}

	return advert, nil
}
1165759
func (c *Client) Receive() {
	for msg := range c.Peer.Receive() {

		switch msg := msg.(type) {

		case *Event:
			if event, ok := c.events[msg.Subscription]; ok {
				go event.handler(msg.Arguments, msg.ArgumentsKw)
			} else {
				logger.Println("no handler registered for subscription:", msg.Subscription)
			}

		case *Invocation:
			c.handleInvocation(msg)

		case *Registered:
			c.notifyListener(msg, msg.Request)
		case *Subscribed:
			c.notifyListener(msg, msg.Request)
		case *Unsubscribed:
			c.notifyListener(msg, msg.Request)
		case *Unregistered:
			c.notifyListener(msg, msg.Request)
		case *Result:
			c.notifyListener(msg, msg.Request)
		case *Error:
			c.notifyListener(msg, msg.Request)

		case *Goodbye:
			logger.Println("client received Goodbye message")
			break

		default:
			logger.Println("unhandled message:", msg.MessageType(), msg)
		}
	}
	logger.Println("client closed")

	if c.ReceiveDone != nil {
		c.ReceiveDone <- true
	}
}
645171
func (r FutureGetTransactionResult) Receive() (*btcjson.GetTransactionResult, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal result as a gettransaction result object
	var getTx btcjson.GetTransactionResult
	err = json.Unmarshal(res, &getTx)
	if err != nil {
		return nil, err
	}

	return &getTx, nil
}
950277
func (r FutureSendManyResult) Receive() (*chainhash.Hash, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmashal result as a string.
	var txHash string
	err = json.Unmarshal(res, &txHash)
	if err != nil {
		return nil, err
	}

	return chainhash.NewHashFromStr(txHash)
}
797260
func (r FutureSubmitBlockResult) Receive() error {
	res, err := receiveFuture(r)
	if err != nil {
		return err
	}

	if string(res) != "null" {
		var result string
		err = json.Unmarshal(res, &result)
		if err != nil {
			return err
		}

		return errors.New(result)
	}

	return nil

}
47518
func (c *Conn) Receive() (*Message, error) {
	rv, err := Receive(c.conn, c.buf)
	if err != nil {
		return nil, err
	}
	return &rv, nil
}
633964
func (c *MockConnection) Receive(eventch chan<- interface{}) {
	result, ok := c.Result(Connect)
	if ok {
		switch result.Result {
		case BadRequestResult:
			eventch <- c.newDeliverStatusResponse(cb.Status_BAD_REQUEST)
			return
		case ForbiddenResult:
			eventch <- c.newDeliverStatusResponse(cb.Status_FORBIDDEN)
			return
		}
	}
	c.MockConnection.Receive(eventch)
}
831386
func (r FutureGetBlockVerboseResult) Receive() (*btcjson.GetBlockVerboseResult, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal the raw result into a BlockResult.
	var blockResult btcjson.GetBlockVerboseResult
	err = json.Unmarshal(res, &blockResult)
	if err != nil {
		return nil, err
	}
	return &blockResult, nil
}
245023
func (r FutureGetCFilterResult) Receive() (*wire.MsgCFilter, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal result as a string.
	var filterHex string
	err = json.Unmarshal(res, &filterHex)
	if err != nil {
		return nil, err
	}

	// Decode the serialized cf hex to raw bytes.
	serializedFilter, err := hex.DecodeString(filterHex)
	if err != nil {
		return nil, err
	}

	// Assign the filter bytes to the correct field of the wire message.
	// We aren't going to set the block hash or extended flag, since we
	// don't actually get that back in the RPC response.
	var msgCFilter wire.MsgCFilter
	msgCFilter.Data = serializedFilter
	return &msgCFilter, nil
}
569069
func (c *PacketConn) Read(b []byte) (int, error) {
	bytesRead, _, err := c.ReadFrom(b)
	return bytesRead, err
}
90385
func (r FutureGetBalanceParseResult) Receive() (btcutil.Amount, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return 0, err
	}

	// Unmarshal result as a string
	var balanceString string
	err = json.Unmarshal(res, &balanceString)
	if err != nil {
		return 0, err
	}

	balance, err := strconv.ParseFloat(balanceString, 64)
	if err != nil {
		return 0, err
	}
	amount, err := btcutil.NewAmount(balance)
	if err != nil {
		return 0, err
	}

	return amount, nil
}
597462
func (r FutureGetCFilterHeaderResult) Receive() (*wire.MsgCFHeaders, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal result as a string.
	var headerHex string
	err = json.Unmarshal(res, &headerHex)
	if err != nil {
		return nil, err
	}

	// Assign the decoded header into a hash
	headerHash, err := chainhash.NewHashFromStr(headerHex)
	if err != nil {
		return nil, err
	}

	// Assign the hash to a headers message and return it.
	msgCFHeaders := wire.MsgCFHeaders{PrevFilterHeader: *headerHash}
	return &msgCFHeaders, nil

}
685854
func (s *Server) ReceivePacket(c net.PacketConn) (Packet, error) {
	return s.readFromConnection(c)
}
1134803
func (m *MonitorCommand) Receive() (string, error) {
	rp, err := m.conn.RecvReply()
	if err != nil {
		return "", err
	}
	return rp.StatusValue()
}
327897
func (r FutureGetTxOutResult) Receive() (*btcjson.GetTxOutResult, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// take care of the special case where the output has been spent already
	// it should return the string "null"
	if string(res) == "null" {
		return nil, nil
	}

	// Unmarshal result as an gettxout result object.
	var txOutInfo *btcjson.GetTxOutResult
	err = json.Unmarshal(res, &txOutInfo)
	if err != nil {
		return nil, err
	}

	return txOutInfo, nil
}
425862
func (adaptor Adapter) Receive() []*api.RunnerResult {
	params := &sqs.ReceiveMessageInput{
		QueueUrl:            aws.String(adaptor.QueueURL),
		MaxNumberOfMessages: aws.Int64(10),
		VisibilityTimeout:   aws.Int64(1),
		WaitTimeSeconds:     aws.Int64(1),
	}
	resp, err := adaptor.Client.ReceiveMessage(params)

	if err != nil {
		fmt.Println(err.Error())
		return nil
	}

	if len(resp.Messages) == 0 {
		return nil
	}

	items := resp.Messages
	results := make([]*api.RunnerResult, 0)
	deleteEntries := make([]*sqs.DeleteMessageBatchRequestEntry, 0)
	for _, item := range items {
		result, jsonerr := resultFromJSON(*item.Body)
		if jsonerr != nil {
			fmt.Println(err.Error())
			return nil
		}
		deleteEntries = append(deleteEntries, &sqs.DeleteMessageBatchRequestEntry{
			Id:            aws.String(*item.MessageId),
			ReceiptHandle: aws.String(*item.ReceiptHandle),
		})
		results = append(results, result)
	}

	deleteParams := &sqs.DeleteMessageBatchInput{
		Entries:  deleteEntries,
		QueueUrl: aws.String(adaptor.QueueURL),
	}
	_, delerr := adaptor.Client.DeleteMessageBatch(deleteParams)

	if delerr != nil {
		fmt.Println(delerr.Error())
		return nil
	}

	return results
}