@param Socket $socket
@param $room

@return Channel
547144
public function join(int $fd, $room): self
    {
        $this->room->add($fd, $this->filterGetRooms($room));

        return $this;
    }
777112
public function info($channel, $message, array $context = [])
    {
        $this->log($channel, LogLevel::INFO, $message, $context);

        return $this;
    }
94303
public function setChannel($channel)
    {
        $this->removeTarget();

        if ($channel) {
            $this->channel = (string) $channel;
        }

        return $this;
    }
841400
public function createChannel(Channel $channel)
    {
        $op = $this->sendCreateChannelOperation($channel);

        // waiting for create operation finishes
        $op = $this->awaitOperation($op);

        if ($op->getState() != OperationState::Succeeded) {
            return null;
        }

        // get and return the createChannel
        return $this->getChannel($op->getTargetEntityId());
    }
440410
public function setUnixSocket( ?string $socket ) : MySQL
   {

      if ( ! $this->_supportedAttributes->get( 'unix_socket' )->validateValue( $socket ) )
      {
         throw new ArgumentException( 'socket', $socket, 'Invalid unix socket!' );
      }

      $this->_attributes[ 'unix_socket' ] = $socket;

      return $this;

   }
795003
protected function socket_send($socket, $message)
	{
		$serialized_message = @serialize($message);
		if ($serialized_message == false)
		{
			$this->log('socket_send failed to serialize message', self::LOG_LEVEL_CRIT);
			return false;
		}

		$header = pack('N', strlen($serialized_message));
		$data = $header . $serialized_message;
		$bytes_left = strlen($data);
		while ($bytes_left > 0)
		{
			$bytes_sent = @socket_write($socket, $data);
			if ($bytes_sent === false)
			{
				$this->log('socket_send error: ' . socket_strerror(socket_last_error()), self::LOG_LEVEL_CRIT);
				return false;
			}

			$bytes_left -= $bytes_sent;
			$data = substr($data, $bytes_sent);
		}

		return true;
	}
596316
protected function bindRoom(): void
    {
        $this->app->singleton(RoomContract::class, function (Container $container) {
            $config = $container->make('config');
            $driver = $config->get('swoole_websocket.default');
            $settings = $config->get("swoole_websocket.settings.{$driver}");
            $className = $config->get("swoole_websocket.drivers.{$driver}");

            // create room instance and initialize
            $room = $this->createRoom($className, $settings);
            $room->prepare();

            return $room;
        });

        $this->app->alias(RoomContract::class, 'swoole.room');
    }
1063000
public function channel(string $channel): Observable
    {
        // Only join a channel once
        if (isset($this->channels[$channel])) {
            return $this->channels[$channel];
        }

        // Ensure we only get messages for the given channel
        $channelMessages = $this->messages->filter(function (Event $event) use ($channel) {
            return $event->getChannel() !== '' && $event->getChannel() === $channel;
        });

        $subscribe = $this->connected
            ->do(function () use ($channel) {
                // Subscribe to pusher channel after connected
                $this->send(Event::subscribeOn($channel));
            })
            ->flatMapTo(Observable::empty());

        // Observable representing channel events
        $this->channels[$channel] = $channelMessages
            ->merge($subscribe)
            ->filter([Event::class, 'subscriptionSucceeded'])
            ->retryWhen(function (Observable $errors) {
                return $errors->flatMap(function (Throwable $throwable) {
                    return $this->handleLowLevelError($throwable);
                });
            })
            ->finally(function () use ($channel) {
                // Send unsubscribe event
                $this->send(Event::unsubscribeOn($channel));

                // Remove our channel from the channel list so we don't resubscribe in case we reconnect
                unset($this->channels[$channel]);
            })
            ->singleInstance();

        return $this->channels[$channel];
    }
1216512
public function addChannel($channel, $key = null)
    {
        $channel = strtolower($channel);
        $this->channels[$channel] = $key;
        return $this;
    }
386057
public function join($rooms): self
    {
        $rooms = is_string($rooms) || is_integer($rooms) ? func_get_args() : $rooms;

        $this->room->add($this->sender, $rooms);

        return $this;
    }
248093
public function critical($channel, $message, array $context = [])
    {
        $this->log($channel, LogLevel::CRITICAL, $message, $context);

        return $this;
    }
1201326
def delete_room(room, reason=''):
    """"""

    if room.custom_server:
        return

    def _delete_room(xmpp):
        muc = xmpp.plugin['xep_0045']
        muc.destroy(room.jid, reason=reason)

    current_plugin.logger.info('Deleting room %s', room.jid)
    _execute_xmpp(_delete_room)
    delete_logs(room)
709793
private static function run(Channel $channel, Socket\ClientSocket $socket = null): Promise
    {
        /** @noinspection PhpDeprecationInspection */
        self::$client = new IpcClient(self::callableFromStaticMethod("onReceivedMessage"), $channel, $socket);

        return call(static function () {
            try {
                yield self::$client->run();
            } catch (\Throwable $exception) {
                // Exception rethrown below as part of MultiReasonException.
            }

            list($exceptions) = yield self::terminate();

            if (isset($exception)) {
                $exceptions[] = $exception;
            }

            try {
                yield self::$client->close();
            } catch (\Throwable $exception) {
                $exceptions[] = $exception;
            }

            self::$client = null;

            if (!empty($exceptions)) {
                $exception = new MultiReasonException($exceptions);
                $message = \implode('; ', \array_map(function (\Throwable $exception): string {
                    return $exception->getMessage();
                }, $exceptions));
                throw new ClusterException("Cluster worker failed: " . $message, 0, $exception);
            }
        });
    }
671129
public function channel($channel, $callback, $options = [])
    {
        $this->channels[$channel] = $callback;

        $this->channelOptions[$channel] = $options;

        return $this;
    }
1058455
protected function bindRoom(): void
    {
        $this->app->bind(RoomContract::class, function (App $app) {
            $config = $app->make('config');
            $room   = $config->get('swoole.websocket.room', []);

            $className = Arr::pull($room, 'type', TableRoom::class);

            // create room instance and initialize
            $room = $this->createRoom($className, $room);
            $room->prepare();

            return $room;
        });

        $this->app->bind('swoole.room', RoomContract::class);
    }
988988
public function publish($channel, $message)
    {
        $this->client->publish($channel, Utils::serializeMessage($message));
    }
147601
final public function socketWrite($message = '', $length = null)
	{
		return @socket_write(
			$this->socket,
			"{$message}",
			is_int($length) ? $length : strlen($message)
		);
	}