summaryrefslogtreecommitdiffstats
path: root/lib/App/ImapNotify/Socket/SSL.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/ImapNotify/Socket/SSL.pm')
-rw-r--r--lib/App/ImapNotify/Socket/SSL.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/App/ImapNotify/Socket/SSL.pm b/lib/App/ImapNotify/Socket/SSL.pm
index 18d7ffa..2654cdc 100644
--- a/lib/App/ImapNotify/Socket/SSL.pm
+++ b/lib/App/ImapNotify/Socket/SSL.pm
@@ -8,24 +8,26 @@ use Function::Parameters;
use IO::Socket::SSL;
use Log::Any qw($log);
-method new($class: $host, $port, $deps = {}) {
- $deps->{sock} //= IO::Socket::SSL->new("$host:$port");
- return $class->new_no_defaults($deps);
-}
-
-method new_no_defaults($class: $deps = {}) {
+method new($class: $host, $port) {
my $self = {};
+ $self->{config} = {
+ host => $host,
+ port => $port,
+ };
bless $self, $class;
- $self->{deps} = $deps;
return $self;
}
+method reconnect() {
+ $self->{sock} = IO::Socket::SSL->new("$self->{config}->{host}:$self->{config}->{port}");
+}
+
method readline() {
- return CORE::readline $self->{deps}->{sock};
+ return CORE::readline $self->{sock};
}
method writeline($line) {
- print {$self->{deps}->{sock}} $line;
+ print {$self->{sock}} $line;
}