Process puback messages sent by server

@param string $msg Message
@param int $qos QoS of message
488299
private function processPubAck ($payload, $qos)
    {
        if( strlen($payload) < 2 ) {
            $this->debugMessage("Malformed PUBACK package received");
            return false;
        }

        $package_id = ( ord($payload{0}) << 8 ) + ord($payload{1});
        if( !isset($this->messageQueue[$package_id]) ) {
            $this->debugMessage("Received PUBACK for package we didn't sent?");
            return false;
        }

        unset( $this->messageQueue[$package_id] );
    }
731485
protected function processSubscribe(Session $session, SubscribeMessage $msg)
    {
        // get a subscription group "hash"
        /** @var MatcherInterface $matcher */
        $matcher = $this->getMatcherForMatchType($msg->getMatchType());
        if ($matcher === false) {
            Logger::alert($this,
                "no matching match type for \"" . $msg->getMatchType() . "\" for URI \"" . $msg->getUri() . "\"");

            return;
        }

        if (!$matcher->uriIsValid($msg->getUri(), $msg->getOptions())) {
            $errorMsg = ErrorMessage::createErrorMessageFromMessage($msg);
            $session->sendMessage($errorMsg->setErrorURI('wamp.error.invalid_uri'));

            return;
        }

        $matchHash = $matcher->getMatchHash($msg->getUri(), $msg->getOptions());

        if (!isset($this->subscriptionGroups[$matchHash])) {
            $this->subscriptionGroups[$matchHash] = new SubscriptionGroup($matcher, $msg->getUri(), $msg->getOptions());
        }

        /** @var SubscriptionGroup $subscriptionGroup */
        $subscriptionGroup = $this->subscriptionGroups[$matchHash];
        $subscription      = $subscriptionGroup->processSubscribe($session, $msg);

        $registry = $this->getStateHandlerRegistry();
        if ($registry !== null) {
            $registry->processSubscriptionAdded($subscription);
        }
    }
1343225
public function parseServerFirstMessage($msg)
    {
        $i = $r = $s = false;

        foreach (explode(',', $msg) as $val) {
            list($attr, $aval) = array_map('trim', explode('=', $val, 2));

            switch ($attr) {
            case 'i':
                $this->_iterations = intval($aval);
                $i = true;
                break;

            case 'r':
                /* Beginning of server-provided nonce MUST be the same as the
                 * nonce we provided. */
                if (strpos($aval, $this->_nonce) !== 0) {
                    return false;
                }
                $this->_nonce = $aval;
                $r = true;
                break;

            case 's':
                $this->_salt = base64_decode($aval);
                $s = true;
                break;
            }
        }

        if ($i && $r && $s) {
            $this->_authmsg .= ',' . $msg;
            return true;
        }

        return false;
    }
532917
public function msg($msg)
    {
        $this->log .= date('Y-m-d H:i:s') . ' ' . $msg . "\n";

        if (php_sapi_name() === 'cli') {
            $this->cli->line($msg);
        } else {
            echo $msg . "<br/>\n";
        }
    }
28108
public static function fromMessage(Message $msg)
    {
        $queueStatus = array();
        while ($msg->peek() !== null) {
            $action = $msg->shift();
            $queueStatus[$action] = array(
                'action'    => $action,
                'queue'     => $msg->shift(),
                'busy'      => $msg->shift(),
                'available' => $msg->shift()
            );
        }

        return new self($queueStatus);
    }
1280155
private function log($msg, array $context = array())
    {
        /** @var \Psr\Log\LoggerInterface $logger */
        $logger = $this->container['logger'];
        $logger->log($this->container['log_level'], $msg, $context);
    }
1144639
public function message($msg)
    {
        foreach ($this as $client) {
            try {
                $this->execute(
                    "sendtextmessage",
                    array("msg" => $msg, "target" => $client, "targetmode" => Teamspeak::TEXTMSG_CLIENT)
                );
            } catch (TeamSpeak3_Adapter_ServerQuery_Exception $e) {
                /* ERROR_client_invalid_id */
                if ($e->getCode() != 0x0200) {
                    throw $e;
                }
            }
        }
    }
512807
protected function send($msg)
    {
        $msg .= PHP_EOL;

        return socket_write($this->socket, $msg, strlen($msg));
    }
116493
def _process_msg(self, client, state, reward, isOver):
        
        # in the first message, only state is valid,
        # reward&isOver should be discarded
        if len(client.memory) > 0:
            client.memory[-1].reward = reward
            if isOver:
                # should clear client's memory and put to queue
                self._parse_memory(0, client, True)
            else:
                if len(client.memory) == LOCAL_TIME_MAX + 1:
                    R = client.memory[-1].value
                    self._parse_memory(R, client, False)
        # feed state and return action
        self._on_state(state, client)
413673
public function msgOk ($data = null, $groups = "", $message = "", $httpStatusCode = Response::HTTP_ACCEPTED)
    {
        return $this->responseOk ($data, $groups, $message, $httpStatusCode);
    }
665740
public function publish_async($topic, $message, $qos=0, $retain=0, &$msgid=null)
    {
        # non blocking
        $this->socket->set_non_blocking();

        # set dup 0
        $dup = 0;

        # initial msgid = 0
        $msgid = 0;

        return $this->do_publish($topic, $message, $qos, $retain, $msgid, $dup);
    }
1148456
public function sendMessage(Message $msg)
    {
        if (is_callable($this->sendMessageFunction)) {
            call_user_func_array($this->sendMessageFunction, [$msg]);
        }
    }
719759
public function messageRead($msgid, $flag_read = TRUE)
  {
    $msg = $this->execute("messageget", array("msgid" => $msgid))->toList();

    if($flag_read)
    {
      $this->execute("messageget", array("msgid" => $msgid, "flag" => $flag_read));
    }

    return $msg;
  }
163228
public function messageHandler(PhpAmqpLib\Message\AMQPMessage $message)
    {
        echo "\n--------\n";
        echo $message->body;
        echo "\n--------\n";

        $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
        if ($message->body === 'quit') {
            $message->delivery_info['channel']->basic_cancel($message->delivery_info['consumer_tag']);
        }
    }
1308368
public void publish(int qos, String payload) throws ArtikCloudMqttException {
        MqttMessage mqttMessage = new MqttMessage(payload.getBytes());
        mqttMessage.setQos(qos);
//        System.out.println("****** Thread: " + Thread.currentThread().getName()+ "; MqttSession publishing : "+ "topic: " + publishTopic +"; payload: " + payload);
        try {
            mqttClient.publish(publishMessageTopicPath, mqttMessage, String.valueOf(OperationMode.PUBLISH), operationListener);
        } catch (MqttException e) {
            throw new ArtikCloudMqttException(e);
        }
    }
619492
public function stdout($msg, $status = self::STATUS_OK)
    {
        if (defined('STDOUT')) {
            fwrite(STDOUT, $msg);
        } else {
            echo $msg;
            if (count(\ob_get_status()) !== 0) {
                ob_flush();
            }
        }
        return $this;
    }
1261440
public function stderr($msg, $status = self::STATUS_FAIL)
    {
        $msg = "<strong>".$msg."</strong>";
        $msg = $this->removeColors($msg);
        $msg = $this->replaceEOLs($msg);

        if (defined('STDERR')) {
            fwrite(STDERR, $msg);
        } else {
            echo $msg;
            if (count(\ob_get_status()) !== 0) {
                ob_flush();
            }
        }
        return $this;
    }