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

Added the ability to debug the client #13

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions config/laravel-smpp.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Default SMPP settings
Expand Down Expand Up @@ -75,6 +74,7 @@

'client' => [
'system_type' => 'default',
'null_terminate_octetstrings' => false
'null_terminate_octetstrings' => false,
'debug' => false
]
];
];
17 changes: 9 additions & 8 deletions src/SmppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct(Repository $config)

/**
* Send a single SMS.
*
*
* @param $phone
* @param $message
*
Expand Down Expand Up @@ -106,13 +106,12 @@ public function sendBulk(array $phones, $message)
$this->setupSmpp();
$sender = $this->getSender();

foreach($phones as $idx => $phone) {
foreach ($phones as $idx => $phone) {
try {
$message = (is_array($message) ? $message[$idx] : $message);

$this->sendSms($sender, $phone, $message);
}
catch(Exception $ex) {
} catch (Exception $ex) {
$this->alertSendingError($ex, $phone);
}
}
Expand All @@ -122,7 +121,7 @@ public function sendBulk(array $phones, $message)

/**
* Alert error occured while sending SMSes.
*
*
* @param Exception $ex
* @param int $phone
*/
Expand All @@ -145,11 +144,13 @@ protected function setupSmpp()

try {
$transport->setRecvTimeout($config['timeout']);
$this->smpp = new SmppClient($transport);
$smpp = new SmppClient($transport);
$smpp->debug = $this->config->get('laravel-smpp.client.debug', false);

$transport->open();
$this->smpp->bindTransmitter($config['login'], $config['password']);
$smpp->bindTransmitter($config['login'], $config['password']);

$this->smpp = $smpp;
$this->provider = $provider;

break;
Expand Down Expand Up @@ -243,4 +244,4 @@ protected function getConfig($option)

return Arr::get($this->providers, $key, $default);
}
}
}