Exemple #1
0
 protected function cmd($buffer, $id, $line)
 {
     switch ($line) {
         case strncmp('EHLO ', $line, 4):
             $this->ev_write($id, "250-STARTTLS\r\n");
             $this->ev_write($id, "250 OK ehlo\r\n");
             break;
         case strncmp('HELO ', $line, 4):
             $this->ev_write($id, "250-STARTTLS\r\n");
             $this->ev_write($id, "250 OK helo\r\n");
             break;
         case strncmp('QUIT', $line, 3):
             $this->ev_write($id, "250 OK quit\r\n");
             $this->ev_close($id);
             break;
         case strncmp('STARTTLS', $line, 3):
             $this->ev_write($id, "220 Ready to start TLS\r\n");
             $this->connections[$id]['cnx'] = EventBufferEvent::sslFilter($this->base, $this->connections[$id]['cnx'], $this->ctx, EventBufferEvent::SSL_ACCEPTING, EventBufferEvent::OPT_CLOSE_ON_FREE);
             $this->connections[$id]['cnx']->setCallbacks([$this, "ev_read"], NULL, [$this, 'ev_error'], $id);
             $this->connections[$id]['cnx']->enable(Event::READ | Event::WRITE);
             break;
         default:
             echo 'unknown command: ' . $line . "\n";
             break;
     }
 }