Ejemplo n.º 1
0
 public static function sendUserSystemTextChatMessage($to, $text)
 {
     $packet = new TextChat();
     $packet->setFromSystemUser();
     $packet->to = intval($to);
     $packet->setText($text);
     Server::getInstance()->sendPacket($packet);
 }
Ejemplo n.º 2
0
            $packet = $packet->getPacketFromPacket($pkt);
            $packet->from = $pkt->to;
            $packet->setSendToAll();
            $packet->setText($introduction);
            $client->sendPacket($packet);
            break;
        case Chatroom::TYPE:
            break;
    }
});
swoole_timer_add(30000, function ($interval) use($client, $infiniteCounterHandler) {
    if ($client->isAuthorized()) {
        //send online user chat packet
        $uidList = UserManager::getInstance()->getAllOnlineUsers();
        if (count($uidList) > 1) {
            $chat = new TextChat();
            $chat->from = COUNTER_UID;
            foreach ($uidList as $uid) {
                if ($uid != COUNTER_UID) {
                    $chat->to = $uid;
                    $chat->setText($infiniteCounterHandler->increase());
                    $client->sendPacket($chat);
                }
            }
        }
        /*// send groupchat
          $groupchat = new TextGroupChat();
          $groupchat->from = COUNTER_UID;
          $groupchat->setSendToAll();
          $groupchat->setGroupId(COUNTER_GROUP_ID);
          $groupchat->setText($infiniteCounterHandler->increase());