Skip to content

Commit

Permalink
Merge pull request #6 from ipublikuj/dropnette2
Browse files Browse the repository at this point in the history
Drop Nette 2 support
  • Loading branch information
akadlec authored Feb 14, 2020
2 parents 1da851b + d1f1bb1 commit 8d4d1ae
Show file tree
Hide file tree
Showing 15 changed files with 390 additions and 187 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
/vendor
/composer.lock
tests/*/output
6 changes: 2 additions & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ checks:
build:
environment:
php:
version: 7.2
variables:
NETTE: default
version: 7.3

dependencies:
before:
Expand All @@ -16,7 +14,7 @@ build:
tests:
override:
-
command: 'vendor/bin/tester tests -p php -c ./tests/php.ini-unix --coverage build/logs/clover.xml --coverage-src src'
command: 'vendor/bin/tester -s -p php -c ./tests/php.ini-unix tests --coverage build/logs/clover.xml --coverage-src src'
coverage:
file: build/logs/clover.xml
format: php-clover
Expand Down
21 changes: 0 additions & 21 deletions .travis.composer.php

This file was deleted.

14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
language: php

env:
- NETTE=default
- NETTE=~2.4.0

php:
- 7.2
- 7.3

before_install:
# turn off XDebug
- phpenv config-rm xdebug.ini || return 0
- composer self-update

before_script:
- php .travis.composer.php
- composer install --no-interaction --prefer-source --dev
- travis_retry composer install --no-progress --prefer-dist

script:
- vendor/bin/tester -s -p php -c ./tests/php.ini-unix tests

after_failure:
- 'for i in $(find ./tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done'
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
20 changes: 9 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,18 @@
"extra" : {
"ipub" : {
"configuration" : {
"extensions" : {
"mqttClient" : "IPub\\MQTTClient\\DI\\MQTTClientExtension"
}
"extension" : "IPub\\MQTTClient\\DI\\MQTTClientExtension"
}
}
},

"require" : {
"php" : ">=7.2.0",

"nette/di" : "~2.4 || ~3.0",
"nette/utils" : "~2.5 || ~3.0",
"nette/di" : "~3.0",
"nette/utils" : "~3.0",

"binsoul/net-mqtt" : "~0.2",
"binsoul/net-mqtt" : "0.2.1",

"react/promise" : "~2.7",
"react/socket" : "~1.2",
Expand All @@ -57,16 +55,16 @@
},

"require-dev" : {
"nette/bootstrap" : "~2.4 || ~3.0",
"nette/mail" : "~2.4 || ~3.0",
"nette/robot-loader" : "~2.4 || ~3.0",
"nette/bootstrap" : "~3.0",
"nette/mail" : "~3.0",
"nette/robot-loader" : "~3.0",
"nette/safe-stream" : "~2.3",
"nette/tester" : "~2.3",

"tracy/tracy" : "~2.4",

"contributte/event-dispatcher": "~0.5",
"contributte/console": "~0.6",
"contributte/event-dispatcher" : "~0.5",
"contributte/console" : "~0.6",

"pds/skeleton" : "~1.0"
},
Expand Down
47 changes: 28 additions & 19 deletions src/IPub/MQTTClient/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace IPub\MQTTClient\Client;

use Closure;

use Nette;

use React\EventLoop;
Expand All @@ -26,6 +28,7 @@

use BinSoul\Net\Mqtt;

use IPub\MQTTClient\Configuration;
use IPub\MQTTClient\Exceptions;
use IPub\MQTTClient\Flow;

Expand Down Expand Up @@ -59,67 +62,67 @@ final class Client implements IClient
use Nette\SmartObject;

/**
* @var \Closure
* @var Closure
*/
public $onStart = [];

/**
* @var \Closure
* @var Closure
*/
public $onOpen = [];

/**
* @var \Closure
* @var Closure
*/
public $onConnect = [];

/**
* @var \Closure
* @var Closure
*/
public $onDisconnect = [];

/**
* @var \Closure
* @var Closure
*/
public $onClose = [];

/**
* @var \Closure
* @var Closure
*/
public $onPing = [];

/**
* @var \Closure
* @var Closure
*/
public $onPong = [];

/**
* @var \Closure
* @var Closure
*/
public $onPublish = [];

/**
* @var \Closure
* @var Closure
*/
public $onSubscribe = [];

/**
* @var \Closure
* @var Closure
*/
public $onUnsubscribe = [];

/**
* @var \Closure
* @var Closure
*/
public $onMessage = [];

/**
* @var \Closure
* @var Closure
*/
public $onWarning = [];

/**
* @var \Closure
* @var Closure
*/
public $onError = [];

Expand All @@ -129,7 +132,7 @@ final class Client implements IClient
private $loop;

/**
* @var Configuration
* @var Configuration\Broker
*/
private $configuration;

Expand Down Expand Up @@ -204,7 +207,7 @@ final class Client implements IClient
private $writtenFlow;

/**
* @var EventLoop\Timer\TimerInterface[]
* @var EventLoop\TimerInterface[]
*/
private $timer = [];

Expand All @@ -215,13 +218,13 @@ final class Client implements IClient

/**
* @param EventLoop\LoopInterface $eventLoop
* @param Configuration $configuration
* @param Configuration\Broker $configuration
* @param Mqtt\IdentifierGenerator|NULL $identifierGenerator
* @param Mqtt\StreamParser|NULL $parser
*/
public function __construct(
EventLoop\LoopInterface $eventLoop,
Configuration $configuration,
Configuration\Broker $configuration,
Mqtt\IdentifierGenerator $identifierGenerator = NULL,
Mqtt\StreamParser $parser = NULL
) {
Expand Down Expand Up @@ -272,8 +275,10 @@ public function getLoop() : EventLoop\LoopInterface

/**
* {@inheritdoc}
*
* @throws Exceptions\InvalidStateException
*/
public function setConfiguration(Configuration $configuration) : void
public function setConfiguration(Configuration\Broker $configuration) : void
{
if ($this->isConnected() || $this->isConnecting) {
throw new Exceptions\InvalidStateException('Client is connecting or connected to the broker, therefore configuration could not be changed.');
Expand All @@ -284,6 +289,8 @@ public function setConfiguration(Configuration $configuration) : void

/**
* {@inheritdoc}
*
* @throws Exceptions\InvalidStateException
*/
public function getUri() : string
{
Expand Down Expand Up @@ -323,7 +330,7 @@ public function connect() : Promise\ExtendedPromiseInterface
$connection = $this->configuration->getConnection();

if ($connection->getClientID() === '') {
$connection = $connection->withClientID($this->identifierGenerator->generateClientID());
$connection->setClientID($this->identifierGenerator->generateClientID());
}

$deferred = new Promise\Deferred;
Expand Down Expand Up @@ -473,6 +480,8 @@ function (\Exception $e) use ($deferred) {
* Establishes a network connection to a server
*
* @return Promise\ExtendedPromiseInterface
*
* @throws Exceptions\InvalidStateException
*/
private function establishConnection() : Promise\ExtendedPromiseInterface
{
Expand Down
6 changes: 4 additions & 2 deletions src/IPub/MQTTClient/Client/IClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

use BinSoul\Net\Mqtt;

use IPub\MQTTClient\Configuration;

/**
* Connection client interface
*
Expand All @@ -42,11 +44,11 @@ function setLoop(EventLoop\LoopInterface $loop);
function getLoop() : EventLoop\LoopInterface;

/**
* @param Configuration $configuration
* @param Configuration\Broker $configuration
*
* @return void
*/
function setConfiguration(Configuration $configuration) : void;
function setConfiguration(Configuration\Broker $configuration) : void;

/**
* Return the host
Expand Down
3 changes: 3 additions & 0 deletions src/IPub/MQTTClient/Commands/ClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use BinSoul\Net\Mqtt;

use IPub\MQTTClient\Client;
use IPub\MQTTClient\Exceptions;
use IPub\MQTTClient\Logger;

/**
Expand Down Expand Up @@ -73,6 +74,8 @@ public function __construct(
* @param Log\LoggerInterface $logger
*
* @return void
*
* @throws Exceptions\InvalidStateException
*/
public function setLogger(Log\LoggerInterface $logger) : void
{
Expand Down
Loading

0 comments on commit 8d4d1ae

Please sign in to comment.