A request to subscribe to a topic has been made.

@param \Ratchet\ConnectionInterface $conn
@param string|Topic                 $topic The topic to subscribe to
199729
public function onSubscribe(ConnectionInterface $conn, $topic)
    {
        $this->console->info("onSubscribe: {$conn->WAMP->sessionId} topic: $topic {$topic->count()}");

        if (!array_key_exists($topic->getId(), $this->subscribedTopics)) {
            $this->subscribedTopics[$topic->getId()] = $topic;
            $this->console->info("subscribed to topic $topic");
        }
    }
738159
protected function subscribe(ConnectionInterface $connection, stdClass $payload)
    {
        $channel = $this->channelManager->findOrCreate($connection->app->id, $payload->channel);

        $channel->subscribe($connection, $payload);
    }
47525
public function subscribeToTopic($topicArn, $protocol, $endpoint)
    {
        // Check against the current Topic Subscriptions
        $subscriptions = $this->getTopicSubscriptions($topicArn);
        foreach ($subscriptions as $subscription) {
            if ($endpoint === $subscription['Endpoint']) {
                return $subscription['SubscriptionArn'];
            }
        }

        $result = $this->sns->subscribe([
            'TopicArn' => $topicArn,
            'Protocol' => $protocol,
            'Endpoint' => $endpoint
        ]);

        $arn = $result->get('SubscriptionArn');

        $context = [
            'Endpoint' => $endpoint,
            'Protocol' => $protocol,
            'SubscriptionArn' => $arn
        ];
        $this->log(200, "Endpoint Subscribed to SNS Topic", $context);

        return $arn;
    }
1012863
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[MxmapTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . MxmapTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(MxmapTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = 'id';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_TRACKUID)) {
            $modifiedColumns[':p' . $index++]  = 'trackUID';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_GBXMAPNAME)) {
            $modifiedColumns[':p' . $index++]  = 'gbxMapName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_TRACKID)) {
            $modifiedColumns[':p' . $index++]  = 'trackID';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_USERID)) {
            $modifiedColumns[':p' . $index++]  = 'userID';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_USERNAME)) {
            $modifiedColumns[':p' . $index++]  = 'username';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_UPLOADEDAT)) {
            $modifiedColumns[':p' . $index++]  = 'uploadedAt';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_UPDATEDAT)) {
            $modifiedColumns[':p' . $index++]  = 'updatedAt';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_MAPTYPE)) {
            $modifiedColumns[':p' . $index++]  = 'mapType';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_TITLEPACK)) {
            $modifiedColumns[':p' . $index++]  = 'titlePack';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_STYLENAME)) {
            $modifiedColumns[':p' . $index++]  = 'styleName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_DISPLAYCOST)) {
            $modifiedColumns[':p' . $index++]  = 'displayCost';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_MODNAME)) {
            $modifiedColumns[':p' . $index++]  = 'modName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_LIGHTMAP)) {
            $modifiedColumns[':p' . $index++]  = 'lightMap';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_EXEVERSION)) {
            $modifiedColumns[':p' . $index++]  = 'exeVersion';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_EXEBUILD)) {
            $modifiedColumns[':p' . $index++]  = 'exeBuild';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_ENVIRONMENTNAME)) {
            $modifiedColumns[':p' . $index++]  = 'environmentName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_VEHICLENAME)) {
            $modifiedColumns[':p' . $index++]  = 'vehicleName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_UNLIMITERREQUIRED)) {
            $modifiedColumns[':p' . $index++]  = 'unlimiterRequired';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_ROUTENAME)) {
            $modifiedColumns[':p' . $index++]  = 'routeName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_LENGTHNAME)) {
            $modifiedColumns[':p' . $index++]  = 'lengthName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_LAPS)) {
            $modifiedColumns[':p' . $index++]  = 'laps';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_DIFFICULTYNAME)) {
            $modifiedColumns[':p' . $index++]  = 'difficultyName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_REPLAYTYPENAME)) {
            $modifiedColumns[':p' . $index++]  = 'replayTypeName';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_REPLAYWRID)) {
            $modifiedColumns[':p' . $index++]  = 'replayWRID';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_REPLAYWRTIME)) {
            $modifiedColumns[':p' . $index++]  = 'replayWRTime';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_REPLAYWRUSERID)) {
            $modifiedColumns[':p' . $index++]  = 'replayWRUserID';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_REPLAYWRUSERNAME)) {
            $modifiedColumns[':p' . $index++]  = 'replayWRUsername';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_RATINGVOTECOUNT)) {
            $modifiedColumns[':p' . $index++]  = 'ratingVoteCount';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_RATINGVOTEAVERAGE)) {
            $modifiedColumns[':p' . $index++]  = 'ratingVoteAverage';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_REPLAYCOUNT)) {
            $modifiedColumns[':p' . $index++]  = 'replayCount';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_TRACKVALUE)) {
            $modifiedColumns[':p' . $index++]  = 'trackValue';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_COMMENTS)) {
            $modifiedColumns[':p' . $index++]  = 'comments';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_COMMENTSCOUNT)) {
            $modifiedColumns[':p' . $index++]  = 'commentsCount';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_AWARDCOUNT)) {
            $modifiedColumns[':p' . $index++]  = 'awardCount';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_HASSCREENSHOT)) {
            $modifiedColumns[':p' . $index++]  = 'hasScreenshot';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_HASTHUMBNAIL)) {
            $modifiedColumns[':p' . $index++]  = 'hasThumbnail';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_HASGHOSTBLOCKS)) {
            $modifiedColumns[':p' . $index++]  = 'hasGhostblocks';
        }
        if ($this->isColumnModified(MxmapTableMap::COL_EMBEDDEDOBJECTSCOUNT)) {
            $modifiedColumns[':p' . $index++]  = 'embeddedObjectsCount';
        }

        $sql = sprintf(
            'INSERT INTO mxmap (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'id':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'trackUID':
                        $stmt->bindValue($identifier, $this->trackuid, PDO::PARAM_STR);
                        break;
                    case 'gbxMapName':
                        $stmt->bindValue($identifier, $this->gbxmapname, PDO::PARAM_STR);
                        break;
                    case 'trackID':
                        $stmt->bindValue($identifier, $this->trackid, PDO::PARAM_INT);
                        break;
                    case 'userID':
                        $stmt->bindValue($identifier, $this->userid, PDO::PARAM_INT);
                        break;
                    case 'username':
                        $stmt->bindValue($identifier, $this->username, PDO::PARAM_STR);
                        break;
                    case 'uploadedAt':
                        $stmt->bindValue($identifier, $this->uploadedat ? $this->uploadedat->format("Y-m-d H:i:s.u") : null, PDO::PARAM_STR);
                        break;
                    case 'updatedAt':
                        $stmt->bindValue($identifier, $this->updatedat ? $this->updatedat->format("Y-m-d H:i:s.u") : null, PDO::PARAM_STR);
                        break;
                    case 'mapType':
                        $stmt->bindValue($identifier, $this->maptype, PDO::PARAM_STR);
                        break;
                    case 'titlePack':
                        $stmt->bindValue($identifier, $this->titlepack, PDO::PARAM_STR);
                        break;
                    case 'styleName':
                        $stmt->bindValue($identifier, $this->stylename, PDO::PARAM_STR);
                        break;
                    case 'displayCost':
                        $stmt->bindValue($identifier, $this->displaycost, PDO::PARAM_INT);
                        break;
                    case 'modName':
                        $stmt->bindValue($identifier, $this->modname, PDO::PARAM_STR);
                        break;
                    case 'lightMap':
                        $stmt->bindValue($identifier, $this->lightmap, PDO::PARAM_INT);
                        break;
                    case 'exeVersion':
                        $stmt->bindValue($identifier, $this->exeversion, PDO::PARAM_STR);
                        break;
                    case 'exeBuild':
                        $stmt->bindValue($identifier, $this->exebuild, PDO::PARAM_STR);
                        break;
                    case 'environmentName':
                        $stmt->bindValue($identifier, $this->environmentname, PDO::PARAM_STR);
                        break;
                    case 'vehicleName':
                        $stmt->bindValue($identifier, $this->vehiclename, PDO::PARAM_STR);
                        break;
                    case 'unlimiterRequired':
                        $stmt->bindValue($identifier, (int) $this->unlimiterrequired, PDO::PARAM_INT);
                        break;
                    case 'routeName':
                        $stmt->bindValue($identifier, $this->routename, PDO::PARAM_STR);
                        break;
                    case 'lengthName':
                        $stmt->bindValue($identifier, $this->lengthname, PDO::PARAM_STR);
                        break;
                    case 'laps':
                        $stmt->bindValue($identifier, $this->laps, PDO::PARAM_INT);
                        break;
                    case 'difficultyName':
                        $stmt->bindValue($identifier, $this->difficultyname, PDO::PARAM_STR);
                        break;
                    case 'replayTypeName':
                        $stmt->bindValue($identifier, $this->replaytypename, PDO::PARAM_STR);
                        break;
                    case 'replayWRID':
                        $stmt->bindValue($identifier, $this->replaywrid, PDO::PARAM_INT);
                        break;
                    case 'replayWRTime':
                        $stmt->bindValue($identifier, $this->replaywrtime, PDO::PARAM_INT);
                        break;
                    case 'replayWRUserID':
                        $stmt->bindValue($identifier, $this->replaywruserid, PDO::PARAM_INT);
                        break;
                    case 'replayWRUsername':
                        $stmt->bindValue($identifier, $this->replaywrusername, PDO::PARAM_STR);
                        break;
                    case 'ratingVoteCount':
                        $stmt->bindValue($identifier, $this->ratingvotecount, PDO::PARAM_INT);
                        break;
                    case 'ratingVoteAverage':
                        $stmt->bindValue($identifier, $this->ratingvoteaverage, PDO::PARAM_STR);
                        break;
                    case 'replayCount':
                        $stmt->bindValue($identifier, $this->replaycount, PDO::PARAM_INT);
                        break;
                    case 'trackValue':
                        $stmt->bindValue($identifier, $this->trackvalue, PDO::PARAM_INT);
                        break;
                    case 'comments':
                        $stmt->bindValue($identifier, $this->comments, PDO::PARAM_STR);
                        break;
                    case 'commentsCount':
                        $stmt->bindValue($identifier, $this->commentscount, PDO::PARAM_INT);
                        break;
                    case 'awardCount':
                        $stmt->bindValue($identifier, $this->awardcount, PDO::PARAM_INT);
                        break;
                    case 'hasScreenshot':
                        $stmt->bindValue($identifier, (int) $this->hasscreenshot, PDO::PARAM_INT);
                        break;
                    case 'hasThumbnail':
                        $stmt->bindValue($identifier, (int) $this->hasthumbnail, PDO::PARAM_INT);
                        break;
                    case 'hasGhostblocks':
                        $stmt->bindValue($identifier, (int) $this->hasghostblocks, PDO::PARAM_INT);
                        break;
                    case 'embeddedObjectsCount':
                        $stmt->bindValue($identifier, $this->embeddedobjectscount, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
1052519
public function handleConnect($conn) {
        $conn->decor = new IoConnection($conn);
        $conn->decor->resourceId = (int)$conn->stream;

        $uri = $conn->getRemoteAddress();
        $conn->decor->remoteAddress = trim(
            parse_url((strpos($uri, '://') === false ? 'tcp://' : '') . $uri, PHP_URL_HOST),
            '[]'
        );

        $this->app->onOpen($conn->decor);

        $conn->on('data', function ($data) use ($conn) {
            $this->handleData($data, $conn);
        });
        $conn->on('close', function () use ($conn) {
            $this->handleEnd($conn);
        });
        $conn->on('error', function (\Exception $e) use ($conn) {
            $this->handleError($e, $conn);
        });
    }
376205
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[ReferenceTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . ReferenceTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(ReferenceTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`id`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_TYPE)) {
            $modifiedColumns[':p' . $index++]  = '`type`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_TITLE)) {
            $modifiedColumns[':p' . $index++]  = '`title`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_YEAR)) {
            $modifiedColumns[':p' . $index++]  = '`year`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_PUBLISHER)) {
            $modifiedColumns[':p' . $index++]  = '`publisher`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_JOURNAL)) {
            $modifiedColumns[':p' . $index++]  = '`journal`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_NUMBER)) {
            $modifiedColumns[':p' . $index++]  = '`number`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_SCHOOL)) {
            $modifiedColumns[':p' . $index++]  = '`school`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_AUTHOR)) {
            $modifiedColumns[':p' . $index++]  = '`author`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_EDITION)) {
            $modifiedColumns[':p' . $index++]  = '`edition`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_VOLUME)) {
            $modifiedColumns[':p' . $index++]  = '`volume`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_ADDRESS)) {
            $modifiedColumns[':p' . $index++]  = '`address`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_EDITOR)) {
            $modifiedColumns[':p' . $index++]  = '`editor`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_HOWPUBLISHED)) {
            $modifiedColumns[':p' . $index++]  = '`howpublished`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_NOTE)) {
            $modifiedColumns[':p' . $index++]  = '`note`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_BOOKTITLE)) {
            $modifiedColumns[':p' . $index++]  = '`booktitle`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_PAGES)) {
            $modifiedColumns[':p' . $index++]  = '`pages`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_URL)) {
            $modifiedColumns[':p' . $index++]  = '`url`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_LASTCHECKED)) {
            $modifiedColumns[':p' . $index++]  = '`lastchecked`';
        }
        if ($this->isColumnModified(ReferenceTableMap::COL_MANAGED)) {
            $modifiedColumns[':p' . $index++]  = '`managed`';
        }

        $sql = sprintf(
            'INSERT INTO `kk_trixionary_reference` (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case '`id`':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case '`type`':
                        $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
                        break;
                    case '`title`':
                        $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
                        break;
                    case '`year`':
                        $stmt->bindValue($identifier, $this->year, PDO::PARAM_INT);
                        break;
                    case '`publisher`':
                        $stmt->bindValue($identifier, $this->publisher, PDO::PARAM_STR);
                        break;
                    case '`journal`':
                        $stmt->bindValue($identifier, $this->journal, PDO::PARAM_STR);
                        break;
                    case '`number`':
                        $stmt->bindValue($identifier, $this->number, PDO::PARAM_STR);
                        break;
                    case '`school`':
                        $stmt->bindValue($identifier, $this->school, PDO::PARAM_STR);
                        break;
                    case '`author`':
                        $stmt->bindValue($identifier, $this->author, PDO::PARAM_STR);
                        break;
                    case '`edition`':
                        $stmt->bindValue($identifier, $this->edition, PDO::PARAM_STR);
                        break;
                    case '`volume`':
                        $stmt->bindValue($identifier, $this->volume, PDO::PARAM_STR);
                        break;
                    case '`address`':
                        $stmt->bindValue($identifier, $this->address, PDO::PARAM_STR);
                        break;
                    case '`editor`':
                        $stmt->bindValue($identifier, $this->editor, PDO::PARAM_STR);
                        break;
                    case '`howpublished`':
                        $stmt->bindValue($identifier, $this->howpublished, PDO::PARAM_STR);
                        break;
                    case '`note`':
                        $stmt->bindValue($identifier, $this->note, PDO::PARAM_STR);
                        break;
                    case '`booktitle`':
                        $stmt->bindValue($identifier, $this->booktitle, PDO::PARAM_STR);
                        break;
                    case '`pages`':
                        $stmt->bindValue($identifier, $this->pages, PDO::PARAM_STR);
                        break;
                    case '`url`':
                        $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
                        break;
                    case '`lastchecked`':
                        $stmt->bindValue($identifier, $this->lastchecked ? $this->lastchecked->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case '`managed`':
                        $stmt->bindValue($identifier, (int) $this->managed, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
1064360
public function onOpen(ConnectionInterface $conn, RequestInterface $request = null) {
        if (null === $request) {
            throw new \UnexpectedValueException('$request can not be null');
        }

        $conn->controller = $this->_noopController;

        $uri = $request->getUri();

        $context = $this->_matcher->getContext();
        $context->setMethod($request->getMethod());
        $context->setHost($uri->getHost());

        try {
            $route = $this->_matcher->match($uri->getPath());
        } catch (MethodNotAllowedException $nae) {
            return $this->close($conn, 405, array('Allow' => $nae->getAllowedMethods()));
        } catch (ResourceNotFoundException $nfe) {
            return $this->close($conn, 404);
        }

        if (is_string($route['_controller']) && class_exists($route['_controller'])) {
            $route['_controller'] = new $route['_controller'];
        }

        if (!($route['_controller'] instanceof HttpServerInterface)) {
            throw new \UnexpectedValueException('All routes must implement Ratchet\Http\HttpServerInterface');
        }

        $parameters = [];
        foreach($route as $key => $value) {
            if ((is_string($key)) && ('_' !== substr($key, 0, 1))) {
                $parameters[$key] = $value;
            }
        }
        $parameters = array_merge($parameters, gPsr\parse_query($uri->getQuery() ?: ''));

        $request = $request->withUri($uri->withQuery(gPsr\build_query($parameters)));

        $conn->controller = $route['_controller'];
        $conn->controller->onOpen($conn, $request);
    }
811867
public function handleStop(ConnectionInterface $conn, array $data)
    {
        $connSubscriptions = $this->connStorage->offsetGet($conn);
        $subscription = array_get($connSubscriptions, $data['id']);

        if (!is_null($subscription)) {
            unset($this->subscriptions[$subscription['name']][$subscription['index']]);
            unset($connSubscriptions[$subscription['id']]);
            $this->connStorage->offsetSet($conn, $connSubscriptions);
            $this->callListener(ON_DISCONNECT, [$subscription, $this->rootValue, $this->context]);
        }
    }
999839
public function onOpen(ConnectionInterface $conn)
    {
        $this->conn = $conn;

        $this->attach()->throttle()->limit();
    }
750887
public function onError(ConnectionInterface $conn, \Exception $e) {

        try {
            throw new \Exception($e->getMessage());
        }
        catch(\Exception $e) {
            throw new SocketServiceException(Messenger::error($e->getMessage()));
        }
        finally {
            $conn->close();
        }
    }
1342678
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;


         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(M2PTableMap::COL_MEDIA_ID)) {
            $modifiedColumns[':p' . $index++]  = 'media_id';
        }
        if ($this->isColumnModified(M2PTableMap::COL_PAGE_ID)) {
            $modifiedColumns[':p' . $index++]  = 'page_id';
        }

        $sql = sprintf(
            'INSERT INTO m2p (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'media_id':
                        $stmt->bindValue($identifier, $this->media_id, PDO::PARAM_INT);
                        break;
                    case 'page_id':
                        $stmt->bindValue($identifier, $this->page_id, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        $this->setNew(false);
    }
1037354
protected function sendMessage(ConnectionInterface $conn, $command, array $message = [])
    {
        $message['cmd'] = $command;
        $conn->write(json_encode($message) . PHP_EOL);
    }
1363795
public function dropSchemaIndex(Index $index, $conn = null)
    {
        $statement = 'DROP INDEX ON :'.$index->getLabel().'('.$index->getProperty().')';
        $this->sendCypherQuery($statement, array(), $conn, self::WRITE_QUERY);
    }
1297382
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[VideoTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . VideoTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(VideoTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`id`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_TITLE)) {
            $modifiedColumns[':p' . $index++]  = '`title`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_DESCRIPTION)) {
            $modifiedColumns[':p' . $index++]  = '`description`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_URL)) {
            $modifiedColumns[':p' . $index++]  = '`url`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_IS_TUTORIAL)) {
            $modifiedColumns[':p' . $index++]  = '`is_tutorial`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_ATHLETE)) {
            $modifiedColumns[':p' . $index++]  = '`athlete`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_ATHLETE_ID)) {
            $modifiedColumns[':p' . $index++]  = '`athlete_id`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_UPLOADER_ID)) {
            $modifiedColumns[':p' . $index++]  = '`uploader_id`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_SKILL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`skill_id`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_REFERENCE_ID)) {
            $modifiedColumns[':p' . $index++]  = '`reference_id`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_POSTER_URL)) {
            $modifiedColumns[':p' . $index++]  = '`poster_url`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_PROVIDER)) {
            $modifiedColumns[':p' . $index++]  = '`provider`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_PROVIDER_ID)) {
            $modifiedColumns[':p' . $index++]  = '`provider_id`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_PLAYER_URL)) {
            $modifiedColumns[':p' . $index++]  = '`player_url`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_WIDTH)) {
            $modifiedColumns[':p' . $index++]  = '`width`';
        }
        if ($this->isColumnModified(VideoTableMap::COL_HEIGHT)) {
            $modifiedColumns[':p' . $index++]  = '`height`';
        }

        $sql = sprintf(
            'INSERT INTO `kk_trixionary_video` (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case '`id`':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case '`title`':
                        $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
                        break;
                    case '`description`':
                        $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
                        break;
                    case '`url`':
                        $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
                        break;
                    case '`is_tutorial`':
                        $stmt->bindValue($identifier, (int) $this->is_tutorial, PDO::PARAM_INT);
                        break;
                    case '`athlete`':
                        $stmt->bindValue($identifier, $this->athlete, PDO::PARAM_STR);
                        break;
                    case '`athlete_id`':
                        $stmt->bindValue($identifier, $this->athlete_id, PDO::PARAM_INT);
                        break;
                    case '`uploader_id`':
                        $stmt->bindValue($identifier, $this->uploader_id, PDO::PARAM_INT);
                        break;
                    case '`skill_id`':
                        $stmt->bindValue($identifier, $this->skill_id, PDO::PARAM_INT);
                        break;
                    case '`reference_id`':
                        $stmt->bindValue($identifier, $this->reference_id, PDO::PARAM_INT);
                        break;
                    case '`poster_url`':
                        $stmt->bindValue($identifier, $this->poster_url, PDO::PARAM_STR);
                        break;
                    case '`provider`':
                        $stmt->bindValue($identifier, $this->provider, PDO::PARAM_STR);
                        break;
                    case '`provider_id`':
                        $stmt->bindValue($identifier, $this->provider_id, PDO::PARAM_STR);
                        break;
                    case '`player_url`':
                        $stmt->bindValue($identifier, $this->player_url, PDO::PARAM_STR);
                        break;
                    case '`width`':
                        $stmt->bindValue($identifier, $this->width, PDO::PARAM_INT);
                        break;
                    case '`height`':
                        $stmt->bindValue($identifier, $this->height, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
373689
protected function send($response, Connection $connection, $topic)
    {
        if ($response instanceof NotFoundHttpException) {
            return;
        }
        
        $recipient = array_get($response, 'recipient', config('twostream.response.recipient'));
        $data = array_get($response, 'data', $response);
        
        if ($recipient == 'all') {
            $topic->broadcast($data);
        } elseif ($recipient == 'except') {
            foreach ($topic->getIterator() as $client) {
                if ($client->session != $connection->session) {
                    $client->event($topic->getId(), $data);
                }
            }
        } else {
            if ($recipient == 'requestee') {
                $recipient = $connection->session;
            }
            
            foreach ((array) $recipient as $recipient) {
                if (($sessionId = $this->getUserSessionId($recipient)) || ($sessionId = WsSession::isValidId($recipient) ? $recipient : false)) {
                    foreach ($topic->getIterator() as $client) {
                        if ($client->session == $sessionId) {
                            $client->event($topic->getId(), $data);
                        }
                    }
                } else {
                    throw new InvalidRecipientException($recipient);
                }
            }
        }
    }
618981
def publish(self, topic, message):
        
        if not self.connections:
            raise NSQNoConnections()
        conn = random.choice(list(self.connections))
        conn.publish(topic, message)
1278353
public function subscribe(string $topicName, string $subscribeName, $endPoint, $strategy = null, $contentFormat = null, $topicOwner = null, $createTime = null, $lastModifyTime = null) {
        if(!$topicName || !$subscribeName || !$endPoint){
            return $this->error('参数有误');
        }
        $topic = $this->client->getTopicRef($topicName);
        $attributes = new SubscriptionAttributes($subscribeName, $endPoint, $strategy, $contentFormat, $topicName, $topicOwner, $createTime, $lastModifyTime);
        try{
            $topic->subscribe($attributes);
            return $this->success('创建订阅成功');
        }catch(MnsException $exception){
            return $this->parseException($exception, '创建订阅');
        }
    }