Channel::doSend()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 1
1
<?php
2
3
namespace PEIP\ABS\Channel;
4
5
/*
6
 * This file is part of the PEIP package.
7
 * (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
/**
13
 * PEIP\ABS\Channel\Channel.
14
 *
15
 * @author Timo Michna <timomichna/yahoo.de>
16
 * @implements \PEIP\INF\Channel\Channel, \PEIP\INF\Event\Connectable
17
 */
18
abstract class Channel extends \PEIP\ABS\Base\Connectable implements
19
        \PEIP\INF\Channel\Channel,
20
        \PEIP\INF\Event\Connectable
21
{
22
    protected $name;
23
24
    /**
25
     * @param $name
26
     *
27
     * @return
28
     */
29
    public function __construct($name)
30
    {
31
        $this->name = $name;
32
    }
33
34
    /**
35
     * @return string the channel�s name
36
     */
37
    public function getName()
38
    {
39
        return $this->name;
40
    }
41
42
    /**
43
     * @param \PEIP\INF\Message\Message $message
44
     * @param int                       $timeout
45
     *
46
     * @return
47
     */
48
    public function send(\PEIP\INF\Message\Message $message, $timeout = -1)
49
    {
50
        $this->doFireEvent('preSend', ['MESSAGE' => $message]);
51
        $sent = $this->doSend($message);
52
        $this->doFireEvent('postSend', [
53
            'MESSAGE' => $message,
54
            'SENT'    => $sent,
55
            'TIMEOUT' => $timeout,
56
        ]);
57
    }
58
59
    /**
60
     * @param \PEIP\INF\Message\Message $message
61
     *
62
     * @return
63
     */
64
    abstract protected function doSend(\PEIP\INF\Message\Message $message);
65
}
66