Skip to content

Commit

Permalink
Merge pull request #2 from morvai88/notify
Browse files Browse the repository at this point in the history
Notify action
  • Loading branch information
viktike committed Sep 28, 2023
2 parents 2bb57eb + 523772c commit 4fa7754
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
70 changes: 70 additions & 0 deletions src/PAMI/Message/Action/PJSIPNotifyAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* PJSIPNotify action message.
*
* PHP Version 5
*
* @category Pami
* @package Message
* @subpackage Action
* @author Sperl Viktor <viktike32@gmail.com>
* @license http://marcelog.github.com/PAMI/ Apache License 2.0
* @version SVN: $Id$
* @link http://marcelog.github.com/PAMI/
*
* Copyright 2023 Sperl Viktor <viktike32@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
namespace PAMI\Message\Action;

/**
* PJSIPNotify action message.
*
* PHP Version 5
*
* @category Pami
* @package Message
* @subpackage Action
* @author Sperl Viktor <viktike32@gmail.com>
* @license http://marcelog.github.com/PAMI/ Apache License 2.0
* @link http://marcelog.github.com/PAMI/
*/
class PJSIPNotifyAction extends ActionMessage
{
/**
* Constructor.
*
* @param string $endpoint PJSIP endpoint or URI to receive the notify.
* @param array/string $variables Variable Key-Value pairs / pjsip_notify.conf context (section) name.
*
* @return void
*/
public function __construct($endpoint, $variables)
{
parent::__construct('PJSIPNotify');
if (strpos($endpoint, "@") !== false) {
$this->setKey('URI', $endpoint);
} else {
$this->setKey('Endpoint', $endpoint);
}
if (is_array($variables)) {
foreach ($variables as $key => $value) {
$this->setKey('Variable', $key . '=' . $value);
}
} else {
$this->setKey('Option', $variables);
}
}
}
6 changes: 5 additions & 1 deletion src/PAMI/Message/Action/SIPNotifyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ class SIPNotifyAction extends ActionMessage
* Constructor.
*
* @param string $channel Peer to receive the notify.
* @param array $variables Variable Key-Value pairs.
*
* @return void
*/
public function __construct($channel)
public function __construct($channel, $variables)
{
parent::__construct('SIPnotify');
$this->setKey('Channel', $channel);
foreach ($variables as $key => $value) {
$this->setKey('Variable', $key . '=' . $value);
}
}
}

0 comments on commit 4fa7754

Please sign in to comment.