Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transceiver implementation #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions smppclient.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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);
}
}
Expand Down