Connection::receiveMessage()
6734
public function receiveMessage($length = null)
    {
        if (null === $length)
            return stream_get_contents($this->getSocketStream());
        $response = null;
        while ($chunk = fread($this->getSocketStream(), 1024)) {
            $response .= $chunk;
            if (substr($chunk, -1) === "\n") {
                break;
            }
        }
        return $response;
    }
1300643
function receive(node, config, socket, message) {

    message.socket = socket.id

    let data = botmgr.buildMessageFlow({ "message" : message }, {
        userId:     'message.socket', 
        convId:     'message.socket',
        payload:    'message.content',
        inputType:  'message.type',
        source:     CARRIER
    })
    

    if (data.message.type === "event") {
        if (data.message.content === "cmd-next") {
            node.warn({'next': data.message})
            return helper.emitEvent('endSound', node);
        }
    }
    else {
        node.warn({'received': data.message})

        // Handle Prompt
        let convId  = botmgr.getConvId(data)
        if (botmgr.hasDelayedCallback(convId, data.message)) return;
    }

    // Trigger received message
    helper.emitEvent('received', node, data, config);
    node.send(data);
}
1309473
public function receive()
	{
		$input = file_get_contents('php://input');

		if (
			$this->logger !== null &&
			$this->logger->isHandling(Logger::DEBUG)
		) {
			$this->logger->addDebug(
				'Receive request',
				array(
					 'request' => ctype_print($input) ? $input : 'base64:' . base64_encode($input)
				)
			);
		}

		return $input;
	}
362294
def receive_message(sock, request_id, max_message_size=MAX_MESSAGE_SIZE):
    """"""
    # Ignore the response's request id.
    length, _, response_to, op_code = _UNPACK_HEADER(
        _receive_data_on_socket(sock, 16))
    # No request_id for exhaust cursor "getMore".
    if request_id is not None:
        if request_id != response_to:
            raise ProtocolError("Got response id %r but expected "
                                "%r" % (response_to, request_id))
    if length <= 16:
        raise ProtocolError("Message length (%r) not longer than standard "
                            "message header size (16)" % (length,))
    if length > max_message_size:
        raise ProtocolError("Message length (%r) is larger than server max "
                            "message size (%r)" % (length, max_message_size))
    if op_code == 2012:
        op_code, _, compressor_id = _UNPACK_COMPRESSION_HEADER(
            _receive_data_on_socket(sock, 9))
        data = decompress(
            _receive_data_on_socket(sock, length - 25), compressor_id)
    else:
        data = _receive_data_on_socket(sock, length - 16)

    try:
        unpack_reply = _UNPACK_REPLY[op_code]
    except KeyError:
        raise ProtocolError("Got opcode %r but expected "
                            "%r" % (op_code, _UNPACK_REPLY.keys()))
    return unpack_reply(data)
569128
def receive(self, msg):
        '''
        
        '''
        handler = getattr(self, 'receive_' + msg.__class__.__name__.lower(), None)
        if handler is None:
            raise InvalidMessageError('Receiving class does not support messages of type: ' + msg.__class__.__name__)
        return handler(msg)
240986
private void receiveMessage(ClientSocket client, DataInputStream buffer, byte from, StateConnection expected)
            throws IOException
    {
        if (ServerImpl.checkValidity(client, from, expected))
        {
            final byte dest = buffer.readByte();
            final byte type = buffer.readByte();
            final int size = buffer.readInt();
            if (size > 0)
            {
                final byte[] clientData = new byte[size];
                if (buffer.read(clientData) != -1) // CHECKSTYLE IGNORE LINE: TrailingComment|NestedIfDepth
                {
                    final DataInputStream clientBuffer = new DataInputStream(new ByteArrayInputStream(clientData));
                    decodeMessage(type, from, dest, clientBuffer);
                }
            }
            final int headerSize = 4;
            bandwidth += headerSize + size;
        }
    }
760577
function receive(msg, rinfo){
    var packet = lob.decloak(msg);
    if(!packet) packet = lob.decode(msg); // accept un-encrypted discovery broadcast hints
    if(!packet) return mesh.log.info('dropping invalid packet from',rinfo,msg.toString('hex'));
    tp.pipe(false, {type:'udp4',ip:rinfo.address,port:rinfo.port}, function(pipe){
      mesh.receive(packet, pipe);
    });
  }
380586
public function receiveMessage($message, WorkflowEngine $workflowEngine)
    {
        if ($message instanceof WorkflowMessage) {
            if (MessageNameUtils::isProcessingCommand($message->messageName())) {
                $this->perform($workflowEngine, $message);
                return;
            }

            $this->assertTaskEntryExists($message->processTaskListPosition());

            $this->recordThat(TaskEntryMarkedAsDone::at($message->processTaskListPosition()));

            $this->perform($workflowEngine, $message);
            return;
        }

        if ($message instanceof LogMessage) {
            $this->assertTaskEntryExists($message->processTaskListPosition());

            $this->recordThat(LogMessageReceived::record($message));

            if ($message->isError()) {
                $this->recordThat(TaskEntryMarkedAsFailed::at($message->processTaskListPosition()));
            } elseif ($this->isSubProcess() && $this->syncLogMessages) {
                //We only sync non error messages, because errors are always synced and then they would be received twice
                $messageForParent = $message->reconnectToProcessTask($this->parentTaskListPosition);
                $workflowEngine->dispatch($messageForParent);
            }
        }
    }
733792
protected function receive($multiline = false)
    {
        $result = @fgets($this->socket);
        $status = $result = trim($result);
        $message = '';

        if (strpos($result, ' ')) {
            list($status, $message) = explode(' ', $result, 2);
        }

        if ($status != '+OK') {
            return false;
        }

        if ($multiline) {
            $message = '';
            $line = fgets($this->socket);
            while ($line && rtrim($line, "\r\n") != '.') {
                if ($line[0] == '.') {
                    $line = substr($line, 1);
                }
                $this->debug('Receiving: '.$line);
                $message .= $line;
                $line = fgets($this->socket);
            };
        }

        return $message;
    }
303401
function fetch() {
		// Unmask payload
		$server=$this->server;
		if (is_bool($buf=$server->read($this->socket)))
			return FALSE;
		$op=ord($buf[0]) & WS::OpCode;
		$len=ord($buf[1]) & WS::Length;
		$pos=2;
		if ($len==0x7e) {
			$len=ord($buf[2])*256+ord($buf[3]);
			$pos+=2;
		}
		else
		if ($len==0x7f) {
			for ($i=0,$len=0;$i<8;$i++)
				$len=$len*256+ord($buf[$i+2]);
			$pos+=8;
		}
		for ($i=0,$mask=[];$i<4;$i++)
			$mask[$i]=ord($buf[$pos+$i]);
		$pos+=4;
		if (strlen($buf)<$len+$pos)
			return FALSE;
		for ($i=0,$data='';$i<$len;$i++)
			$data.=chr(ord($buf[$pos+$i])^$mask[$i%4]);
		// Dispatch
		switch ($op & WS::OpCode) {
		case WS::Ping:
			$this->send(WS::Pong);
			break;
		case WS::Close:
			$server->close($this->socket);
			break;
		case WS::Text:
			$data=trim($data);
		case WS::Binary:
			if (isset($this->events['receive']) &&
				is_callable($func=$this->events['receive']))
				$func($this,$op,$data);
			break;
		}
		return [$op,$data];
	}
74390
public function receiveMessage()
    {
        $response = $this->client->receiveMessage(['QueueUrl' => $this->queueName]);

        if (empty($response['Messages'])) {
            return false;
        }
        $data = reset($response['Messages']);
        return new Message([
            'messageId' => $data['MessageId'],
            'messageBody' => $data['Body'],
            'queue' => $this->queue,
            'receiptHandle' => $data['ReceiptHandle'],
        ]);
    }
1295906
public function read_message()
  {
    socket_recv ( $this->socket , $buf , 8 , MSG_WAITALL );
    if ($buf == null)
      return $buf;
    
    $frame_count = unpack("Nserial/Ncount", $buf);
    $frame_count = $frame_count["count"];
    $message = "";
    for ($i = 0; $i < $frame_count; $i++ ) {
      socket_recv ( $this->socket , $buf , 4 , MSG_WAITALL );
      $frame_size = unpack("Nsize", $buf);
      $frame_size = $frame_size["size"];
      if ($frame_size > 0) {
        socket_recv ( $this->socket , $bif , $frame_size , MSG_WAITALL );
        $message .= $bif;
      }
      
    }
    return $message;
  }
564410
function send_message($eventdata){
        global $CFG;

        // Skip any messaging of suspended and deleted users.
        if ($eventdata->userto->auth === 'nologin' or $eventdata->userto->suspended or $eventdata->userto->deleted) {
            return true;
        }

        if (!empty($CFG->noemailever)) {
            // hidden setting for development sites, set in config.php if needed
            debugging('$CFG->noemailever is active, no jabber message sent.', DEBUG_MINIMAL);
            return true;
        }

        if (PHPUNIT_TEST) {
            // No connection to external servers allowed in phpunit tests.
            return true;
        }

        //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
        static $jabberaddresses = array();

        if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
            $jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', null, $eventdata->userto->id);
        }
        $jabberaddress = $jabberaddresses[$eventdata->userto->id];

        //calling s() on smallmessage causes Jabber to display things like &lt; Jabber != a browser
        $jabbermessage = fullname($eventdata->userfrom).': '.$eventdata->smallmessage;

        if (!empty($eventdata->contexturl)) {
            $jabbermessage .= "\n".get_string('view').': '.$eventdata->contexturl;
        }

        $jabbermessage .= "\n(".get_string('noreply','message').')';

        $conn = new XMPPHP_XMPP($CFG->jabberhost,$CFG->jabberport,$CFG->jabberusername,$CFG->jabberpassword,'moodle',$CFG->jabberserver);

        // No need to track the presence during the sending message process.
        $conn->track_presence = false;

        try {
            //$conn->useEncryption(false);
            $conn->connect();
            $conn->processUntil('session_start');
            $conn->presence();
            $conn->message($jabberaddress, $jabbermessage);
            $conn->disconnect();
        } catch(XMPPHP_Exception $e) {
            debugging($e->getMessage());
            return false;
        }
        return true;
    }
1224583
public function onMessage($connection, $recv_buffer)
    {
        $req_data = json_decode(trim($recv_buffer), true);
        $module = $req_data['module'];
        $interface = $req_data['interface'];
        $cmd = $req_data['cmd'];
        $start_time = isset($req_data['start_time']) ? $req_data['start_time'] : '';
        $end_time = isset($req_data['end_time']) ? $req_data['end_time'] : '';
        $date = isset($req_data['date']) ? $req_data['date'] : '';
        $code = isset($req_data['code']) ? $req_data['code'] : '';
        $msg = isset($req_data['msg']) ? $req_data['msg'] : '';
        $offset = isset($req_data['offset']) ? $req_data['offset'] : '';
        $count = isset($req_data['count']) ? $req_data['count'] : 10;
        switch($cmd)
        {
            case 'get_statistic':
                $buffer = json_encode(array('modules'=>$this->getModules($module), 'statistic' => $this->getStatistic($date, $module, $interface)))."\n";
                $connection->send($buffer);
                break;
            case 'get_log':
                $buffer = json_encode($this->getStasticLog($module, $interface , $start_time , $end_time, $code, $msg, $offset, $count))."\n";
                $connection->send($buffer);
                break;
            default :
                $connection->send('pack err');
        }
    }
509239
function event_receive($client_socket, $events, $client_id)
    {
        $data = Stream::read($client_socket, $this->buffer_size);
        if($data !== false)
        {
            $this->protocol->onReceive($this, $client_id, 0, $data);
        }
        else
        {
            $this->close($client_id);
        }
    }
1098116
@Override
    public void receiveMessage(VoidMessage message) {
        try {
            log.info("Message received, saving...");
            messages.put(message);
        } catch (Exception e) {
            // do nothing
        }
    }
1044579
public function Receive ($reply = FALSE)
	{
		
		// Check the stream is connected
		
		if ($this->_stream === FALSE)
		{
			
			// If not create an error
			
			$this->Error ('Cannot receive data, the stream is not connected!');
			
			// return FALSE
			
			return FALSE;
			
		}
		
		// Set some variables to collect the received data
		
		$recv	= NULL;
		
		// Receive the data from the socket
		
		while (TRUE)
		{
			
			// Append the buffer to the received data
			
			$recv	.= stream_socket_recvfrom ($this->_stream, 4096);
			
			// If the string has been terminated
			
			if (strstr ($recv, "\r\n"))
			{
				
				// Break the loop
				
				break;
				
			}
			
		}
		
		// Development Mode
		
		if ($this->dev)
		{
			
			// Add to log
			
			$this->log[]	= 'Received data: ' . trim ($recv);
			
		}
		
		// If a reply was expected
		
		if ($reply !== FALSE)
		{
			
			// Get the reply code (first 3 characters of the reply)
			
			$replyCode	= substr ($recv, 0, 3);
			
			// If the expected reply is an array
			
			if (is_array ($reply))
			{
				
				// Check to see if the code is in the expected replies array
				
				if (!in_array ($replyCode, $reply))
				{
					
					// The code is not in the array so create an error
					
					$this->Error ('Invalid response: ' . $replyCode);
					
					// return FALSE
					
					return FALSE;
					
				}
				
			}
			
			// If the data is not an array
			
			else
			{
				
				// Check to see if the code is the same as the expected response
				
				if ($replyCode != $reply)
				{
					
					// The code is not the expected reponse so set an error
					
					$this->Error ('Invalid response: ' . $replyCode);
					
					// return FALSE
					
					return FALSE;
					
				}
				
			}
			
			// Development Mode
			
			if ($this->dev)
			{
				
				// Add to log
				
				$this->log[]	= 'Expected Response: ' . $replyCode;
				
			}
			
		}
		
		// return TRUE
		
		return TRUE;
		
	}