getHostmask() 공개 메소드

Returns a hostmask that uniquely identifies the connection.
public getHostmask ( ) : string
리턴 string
예제 #1
0
 /**
  * Removes a connection from the connection list.
  *
  * @param Phergie_Connection|string $connection Instance or hostmask for
  *        the connection to remove
  *
  * @return Phergie_Connection_Handler Provides a fluent interface
  */
 public function removeConnection($connection)
 {
     if ($connection instanceof Phergie_Connection) {
         $hostmask = (string) $connection->getHostmask();
     } elseif (is_string($connection) && isset($this->connections[$connection])) {
         $hostmask = $connection;
     } else {
         return $this;
     }
     unset($this->connections[$hostmask]);
     return $this;
 }
예제 #2
0
 /**
  * Tests that attempting to retrieve a hostmask with all required
  * options is successful.
  *
  * @return void
  */
 public function testGetHostmaskWithValidData()
 {
     $options = array('nick' => 'MyNick', 'username' => 'MyUsername', 'host' => 'example.com');
     $connection = new Phergie_Connection($options);
     $hostmask = $connection->getHostmask();
     $this->assertInstanceOf('Phergie_Hostmask', $hostmask);
 }
예제 #3
0
 /**
  * Overrides the parent class to set the currently active socket handler
  * when the active connection is changed.
  *
  * @param Phergie_Connection $connection Active connection
  *
  * @return Phergie_Driver_Streams Provides a fluent interface
  */
 public function setConnection(Phergie_Connection $connection)
 {
     // Set the active socket handler
     $hostmask = (string) $connection->getHostmask();
     if (!empty($this->sockets[$hostmask])) {
         $this->socket = $this->sockets[$hostmask];
     }
     // Set the active connection
     return parent::setConnection($connection);
 }
예제 #4
0
 /**
  * Outputs a prompt when the bot terminates a connection to a server.
  *
  * @param Phergie_Connection $connection Terminated connection 
  *
  * @return void
  */
 public function onQuit(Phergie_Connection $connection)
 {
     $host = $connection->getHostmask()->getHost();
     $this->console('Disconnecting from ' . $host);
 }