WebSocket::connect PHP Method

connect() public method

public connect ( $socket )
    function connect($socket)
    {
        $user = new User();
        $user->id = uniqid();
        $user->socket = $socket;
        array_push($this->users, $user);
        array_push($this->sockets, $socket);
        $this->log($socket . " CONNECTED!");
    }

Usage Example

Example #1
0
 public function connect($socket)
 {
     // get the connected client's ip
     $client_ip = NULL;
     socket_getpeername($socket, $client_ip);
     // add player to container
     $this->players->addPlayer($client_ip, $socket);
     parent::connect($socket);
     $this->say('with ' . $client_ip);
 }