IClient::getLoop()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
1
<?php
2
/**
3
 * IClient.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:MQTTClient!
9
 * @subpackage     Client
10
 * @since          1.0.0
11
 *
12
 * @date           12.03.17
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\MQTTClient\Client;
18
19
use React\EventLoop;
20
use React\Promise;
21
22
use BinSoul\Net\Mqtt;
23
24
use IPub\MQTTClient\Configuration;
25
26
/**
27
 * Connection client interface
28
 *
29
 * @package        iPublikuj:MQTTClient!
30
 * @subpackage     Client
31
 *
32
 * @author         Adam Kadlec <[email protected]>
33
 */
34 1
interface IClient
35
{
36
	/**
37
	 * @param EventLoop\LoopInterface $loop
38
	 */
39
	function setLoop(EventLoop\LoopInterface $loop);
40
41
	/**
42
	 * @return EventLoop\LoopInterface
43
	 */
44
	function getLoop() : EventLoop\LoopInterface;
45
46
	/**
47
	 * @param Configuration\Broker $configuration
48
	 *
49
	 * @return void
50
	 */
51
	function setConfiguration(Configuration\Broker $configuration) : void;
52
53
	/**
54
	 * Return the host
55
	 *
56
	 * @return string
57
	 */
58
	function getUri() : string;
59
60
	/**
61
	 * Return the port
62
	 *
63
	 * @return int
64
	 */
65
	function getPort() : int;
66
67
	/**
68
	 * Indicates if the client is connected
69
	 *
70
	 * @return bool
71
	 */
72
	function isConnected() : bool;
73
74
	/**
75
	 * Connects to a broker
76
	 *
77
	 * @return Promise\ExtendedPromiseInterface
78
	 */
79
	function connect() : Promise\ExtendedPromiseInterface;
80
81
	/**
82
	 * Disconnects from a broker
83
	 *
84
	 * @return Promise\ExtendedPromiseInterface
85
	 */
86
	function disconnect() : Promise\ExtendedPromiseInterface;
87
88
	/**
89
	 * Subscribes to a topic filter
90
	 *
91
	 * @param Mqtt\Subscription $subscription
92
	 *
93
	 * @return Promise\ExtendedPromiseInterface
94
	 */
95
	function subscribe(Mqtt\Subscription $subscription) : Promise\ExtendedPromiseInterface;
96
97
	/**
98
	 * Unsubscribes from a topic filter
99
	 *
100
	 * @param Mqtt\Subscription $subscription
101
	 *
102
	 * @return Promise\ExtendedPromiseInterface
103
	 */
104
	function unsubscribe(Mqtt\Subscription $subscription) : Promise\ExtendedPromiseInterface;
105
106
	/**
107
	 * Publishes a message
108
	 *
109
	 * @param Mqtt\Message $message
110
	 *
111
	 * @return Promise\ExtendedPromiseInterface
112
	 */
113
	function publish(Mqtt\Message $message) : Promise\ExtendedPromiseInterface;
114
115
	/**
116
	 * Calls the given generator periodically and publishes the return value
117
	 *
118
	 * @param int $interval
119
	 * @param Mqtt\Message $message
120
	 * @param callable $generator
121
	 *
122
	 * @return Promise\ExtendedPromiseInterface
123
	 */
124
	function publishPeriodically(int $interval, Mqtt\Message $message, callable $generator) : Promise\ExtendedPromiseInterface;
125
}
126