示例#1
0
 public function __construct(array $data, ChatRoom $room)
 {
     parent::__construct($data, $room->getIdentifier()->getHost());
     $this->room = $room;
     $this->userId = $data['user_id'];
     $this->userName = $data['user_name'];
 }
示例#2
0
 public function __construct(array $data, ChatRoom $room)
 {
     parent::__construct($data, $room->getIdentifier()->getHost());
     $this->userId = (int) $data['user_id'];
     $this->userName = (string) $data['user_name'];
     $this->roomId = (int) $data['room_id'];
     $this->roomName = (string) $data['room_name'];
 }
示例#3
0
 public function __construct(array $data, ChatRoom $room)
 {
     parent::__construct($data, $room->getIdentifier()->getHost());
     $this->room = $room;
     $this->messageId = $data['message_id'];
     $this->content = $data['content'];
     $this->numberOfStars = $data['message_stars'] ?? 0;
     $this->pinned = isset($data['message_owner_stars']);
 }
示例#4
0
 public function __construct(array $data, ChatRoom $room)
 {
     parent::__construct($data, $room->getIdentifier()->getHost());
     $this->room = $room;
     $this->userId = (int) $data['user_id'];
     $this->userName = (string) $data['user_name'];
     $this->messageId = (int) $data['message_id'];
     $this->messageContent = domdocument_load_html((string) ($data['content'] ?? ''), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
     $this->parentId = (int) ($data['parent_id'] ?? -1);
     $this->showParent = (bool) ($data['show_parent'] ?? false);
 }
示例#5
0
 private function leaveRoom(Room $room) : Promise
 {
     assert(!$room->isPermanent(), new InvalidRoomException('Cannot leave a permanent room'));
     $this->storage->setApproved($room->getIdentifier(), false);
     $this->removeScheduledActionsForUnapprovedRoom($room->getIdentifier());
     $body = (new FormBody())->addField('fkey', $room->getSession()->getFKey())->addField('quiet', 'true');
     $request = (new HttpRequest())->setMethod('POST')->setUri($this->urlResolver->getEndpointURL($room, Endpoint::CHATROOM_LEAVE))->setBody($body);
     $this->storage->removeRoom($room->getIdentifier());
     $room->getWebsocketHandler()->getEndpoint()->close();
     return $this->httpClient->request($request);
 }
示例#6
0
 public function __construct(array $data, ChatRoom $room)
 {
     parent::__construct($data, $room->getIdentifier()->getHost());
 }
示例#7
0
 private function getClientForRoom(ChatRoom $room)
 {
     if (isset($this->clients[$room->getIdentifier()->getIdentString()])) {
         return $this->clients[$room->getIdentifier()->getIdentString()];
     }
     $keys = ['oauth.access_token', 'oauth.access_token_secret'];
     $config = [];
     foreach ($keys as $key) {
         if (!(yield $this->keyValueStore->exists($key, $room))) {
             throw new NotConfiguredException('Missing config key: ' . $key);
         }
         $config[$key] = (yield $this->keyValueStore->get($key, $room));
     }
     $accessToken = $this->accessTokenFactory->create($config['oauth.access_token'], $config['oauth.access_token_secret']);
     $this->clients[$room->getIdentifier()->getIdentString()] = $this->apiClientFactory->create($accessToken);
     return $this->clients[$room->getIdentifier()->getIdentString()];
 }