diff --git a/smppclient.class.php b/smppclient.class.php index 7732471..4e36da0 100644 --- a/smppclient.class.php +++ b/smppclient.class.php @@ -102,14 +102,17 @@ public function __construct(SocketTransport $transport,$debugHandler=null) } /** - * Binds the receiver. One object can be bound only as receiver or only as trancmitter. + * Binds the receiver. One object can be bound as receiver / transmitter / transceiver only. * @param string $login - ESME system_id * @param string $pass - ESME password * @throws SmppException */ public function bindReceiver($login, $pass) { - if (!$this->transport->isOpen()) return false; + if (!$this->transport->isOpen()) { + if($this->debug) call_user_func($this->debugHandler, 'Transport is not open. Exiting'); + return false; + } if($this->debug) call_user_func($this->debugHandler, 'Binding receiver...'); $response = $this->_bind($login, $pass, SMPP::BIND_RECEIVER); @@ -121,14 +124,17 @@ public function bindReceiver($login, $pass) } /** - * Binds the transmitter. One object can be bound only as receiver or only as trancmitter. + * Binds the transmitter. One object can be bound as receiver / transmitter / transceiver only. * @param string $login - ESME system_id * @param string $pass - ESME password * @throws SmppException */ public function bindTransmitter($login, $pass) { - if (!$this->transport->isOpen()) return false; + if (!$this->transport->isOpen()) { + if($this->debug) call_user_func($this->debugHandler, 'Transport is not open. Exiting'); + return false; + } if($this->debug) call_user_func($this->debugHandler, 'Binding transmitter...'); $response = $this->_bind($login, $pass, SMPP::BIND_TRANSMITTER); @@ -138,7 +144,29 @@ public function bindTransmitter($login, $pass) $this->login = $login; $this->pass = $pass; } - + + /** + * Binds the transceiver. One object can be bound as receiver / transmitter / transceiver only. + * @param string $login - ESME system_id + * @param string $pass - ESME password + * @throws SmppException + */ + public function bindTransceiver($login, $pass) + { + if (!$this->transport->isOpen()) { + if($this->debug) call_user_func($this->debugHandler, 'Transport is not open. Exiting'); + return false; + } + if($this->debug) call_user_func($this->debugHandler, 'Binding transceiver...'); + + $response = $this->_bind($login, $pass, SMPP::BIND_TRANSCEIVER); + + if($this->debug) call_user_func($this->debugHandler, "Binding status : ".$response->status); + $this->mode = 'transceiver'; + $this->login = $login; + $this->pass = $pass; + } + /** * Closes the session on the SMSC server. */ @@ -600,7 +628,9 @@ protected function reconnect() if ($this->mode == 'receiver') { $this->bindReceiver($this->login, $this->pass); - } else { + } elseif ($this->mode == 'transceiver') { + $this->bindTransceiver($this->login, $this->pass); + } else { $this->bindTransmitter($this->login, $this->pass); } }