Statusnet.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * Extends the Streams driver (Phergie_Driver_Streams) to give external access
  19. * to the socket resources and send method
  20. *
  21. * @category Phergie
  22. * @package Phergie_Driver_Statusnet
  23. * @author Luke Fitzgerald <lw.fitzgerald@googlemail.com>
  24. * @copyright 2010 StatusNet, Inc.
  25. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  26. * @link http://status.net/
  27. */
  28. class Phergie_Driver_Statusnet extends Phergie_Driver_Streams {
  29. /**
  30. * Handles construction of command strings and their transmission to the
  31. * server.
  32. *
  33. * @param string $command Command to send
  34. * @param string|array $args Optional string or array of sequential
  35. * arguments
  36. *
  37. * @return string Command string that was sent
  38. * @throws Phergie_Driver_Exception
  39. */
  40. public function send($command, $args = '') {
  41. return parent::send($command, $args);
  42. }
  43. public function forceQuit() {
  44. try {
  45. // Send a QUIT command to the server
  46. $this->send('QUIT', 'Reconnecting');
  47. } catch (Phergie_Driver_Exception $e){}
  48. // Terminate the socket connection
  49. fclose($this->socket);
  50. // Remove the socket from the internal socket list
  51. unset($this->sockets[(string) $this->getConnection()->getHostmask()]);
  52. }
  53. /**
  54. * Returns the array of sockets
  55. *
  56. * @return array Array of socket resources
  57. */
  58. public function getSockets() {
  59. return $this->sockets;
  60. }
  61. }