From 50729f6ce475514938b057cf29639d3b194ff739 Mon Sep 17 00:00:00 2001 From: lazos Date: Mon, 26 Sep 2016 23:38:18 +0200 Subject: [PATCH] Added 'tls' option to toggle ws/wss protocol. Added 'path' option to allow changing path of transport URL. --- src/Vinelab/Minion/Minion.php | 12 +++++++++++- tests/unit/MinionTest.php | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Vinelab/Minion/Minion.php b/src/Vinelab/Minion/Minion.php index 5fe1649..fc468c1 100644 --- a/src/Vinelab/Minion/Minion.php +++ b/src/Vinelab/Minion/Minion.php @@ -27,6 +27,8 @@ class Minion 'host' => '127.0.0.1', 'port' => 9090, 'debug' => false, + 'tls' => false, + 'path' => '/ws', ]; /** @@ -105,7 +107,15 @@ public function newTransportProvider() */ public function transportUrl() { - return 'ws://'.$this->getConfig('host').':'.$this->getConfig('port').'/ws'; + $proto = $this->getConfig('tls') ? 'wss' : 'ws'; + $port = intval($this->getConfig('port')); + if($port>0) { + $port = ':'.$port; + } + else { + $port = ''; + } + return $proto.'://'.$this->getConfig('host').$port.$this->getConfig('path'); } /** diff --git a/tests/unit/MinionTest.php b/tests/unit/MinionTest.php index c38728e..2fc50b0 100644 --- a/tests/unit/MinionTest.php +++ b/tests/unit/MinionTest.php @@ -36,6 +36,8 @@ public function test_default_config() 'host' => '127.0.0.1', 'port' => 9090, 'debug' => false, + 'tls' => false, + 'path' => '/ws', ]; $this->assertEquals($default, $this->m->getConfig());