Example #1
0
 public function onInform($event)
 {
     $info = $this->getChatEventInfo($event);
     if ($info[0] == 'U') {
         $temp = packet_get_conts($info, 0, 8);
         if (strcmp($temp, 'User was') == 0 || strcmp($info, 'User is offline') == 0) {
             $this->updateHostStatus($this->last_host_id, self::HOST_STATUS_FREE);
         }
     }
 }
Example #2
0
 public function onJoin(player $player, $packet)
 {
     //check for slots
     if (($new_pid = call_method('getNewPid', $this)) == 0) {
         call_method('onLeave', $this, $player, self::REASON_LEFT);
         call_method('onDisconnect', $this, $player);
     }
     $client_game_port = WORD2INT(toEndian(packet_get_conts($packet, 13, 2)));
     $raw_client_gameport = packet_get_conts($packet, 14, 1) . packet_get_conts($packet, 13, 1);
     $raw_client_event = packet_get_conts($packet, 15, 4);
     $client_username = packet_get_string($packet, 19, self::USERNAME_MAX_LEN, $i);
     $i = $i + 7;
     $raw_client_private_ip_network_byte = packet_get_conts($packet, $i, 4);
     $private_ip = long2ip(DWORD2LONG($raw_client_private_ip_network_byte));
     socket_getpeername($player->socket, $client_ip, $client_port);
     call_method('setName', $player, $client_username);
     call_method('setPid', $player, $new_pid);
     call_method('setRemoteIP', $player, $client_ip);
     call_method('setRemotePort', $player, $client_port);
     call_method('setPublicNodePort', $player, $client_game_port);
     call_method('setPrivateNodeIP', $player, $private_ip);
     call_method('setClientEvent', $player, $raw_client_event);
     /*
     if(!$this->userlist->search(strtolower($client_username)))
     {
     	call_method('onLeave', $this, $player, self::REASON_LEFT);
     	call_method('onDisconnect', $this, $player);
     	return;
     }
     */
     if (call_method('isRequester', $this, $client_username)) {
         //release the reserved slot for the game requester.
         unset($this->reserver_timer);
         call_method('releaseSlot', $this->room, 1);
     }
     //when the player sent the correct packet, mark the player as identified
     call_method('identify', $player);
     call_method('sendOnJoin', $this, $player);
     call_method('sendHostname', $this, $player);
     call_method('exchangePeersInfo', $this, $player);
     call_method('sendMapInfo', $this, $player);
     if (!($slot_index = call_method('insertPlayer', $this->room, call_method('getPid', $player)))) {
         call_method('onLeave', $this, $player, self::REASON_LEFT);
         call_method('onDisconnect', $this, $player);
         return;
     }
     call_method('setSlot', $player, $slot_index);
     foreach ($this->players as $othPlayer) {
         if (call_method('isOffline', $othPlayer)) {
             continue;
         }
         if (call_method('isIdentified', $othPlayer)) {
             call_method('sendUpdatedSlots', $this, $othPlayer);
         }
     }
     call_method('pingAll', $this);
     call_method('whereIs', $this->bot, $client_username);
     ++$this->hits;
 }