/** * Triggered when a client sends data through the socket * @param \Ratchet\ConnectionInterface $from The socket/connection that sent the message to your application * @param string $msg The message received * @throws \Exception */ function onMessage(ConnectionInterface $from, $msg) { $this->manager->debug("onMessage...({$msg})"); /** @var TransportInterface $transport */ $transport = $this->transports[$from]; $this->peer->onMessage($transport, $transport->getSerializer()->deserialize($msg)); }
public function addRealm(Realm $realm) { $realmName = $realm->getRealmName(); if (!static::validRealmName($realm->getRealmName())) { throw new InvalidRealmNameException(); } if (array_key_exists($realm->getRealmName(), $this->realms)) { throw new \Exception("There is already a realm \"" . $realm->getRealmName() . "\""); } $this->manager->debug("Adding realm \"" . $realmName . "\""); if ($realm->getManager() instanceof ManagerDummy) { /** remind people that we don't setup the manager for them if they * are creating their own realms */ $this->manager->warning("Realm \"" . $realmName . "\" is using ManagerDummy"); } $this->realms[$realm->getRealmName()] = $realm; }
/** * @param Session $session */ public function leave(Session $session) { $this->manager->debug("Leaving realm {$session->getRealm()->getRealmName()}"); if ($this->getAuthenticationManager() !== null) { $this->getAuthenticationManager()->onSessionClose($session); } foreach ($this->roles as $role) { $role->leave($session); } }
/** * @param Session $session */ public function leave(Session $session) { $this->registrations->rewind(); while ($this->registrations->valid()) { /* @var $registration Registration */ $registration = $this->registrations->current(); $this->registrations->next(); if ($registration->getSession() == $session) { $this->manager->debug("Leaving and unegistering: {$registration->getProcedureName()}"); $this->registrations->detach($registration); } } }
/** * //@todo make this better * @param Session $session */ public function leave(Session $session) { $this->subscriptions->rewind(); while ($this->subscriptions->valid()) { /* @var $subscription Subscription */ $subscription = $this->subscriptions->current(); $this->subscriptions->next(); if ($subscription->getSession() == $session) { $this->manager->debug("Leaving and unsubscribing: {$subscription->getTopic()}"); $this->subscriptions->detach($subscription); } } foreach ($this->topics as $topicName => $subscribers) { foreach ($subscribers as $key => $subscriber) { if ($session == $subscriber) { unset($subscribers[$key]); $this->manager->debug("Removing session from topic list: {$topicName}"); } } } }