diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-07-19 16:29:32 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-07-19 16:29:32 +0200 |
commit | c66032630f0e4fc3f4b59413a12f9ab35be958be (patch) | |
tree | 267ad62e364f141a6c40ac33e8c03794befdd2ff /lib/App/ImapNotify/Socket/SSL.pm | |
parent | 12e45f6e461696131b8950245ac26f1dc7fb5573 (diff) | |
download | App-ImapNotify-c66032630f0e4fc3f4b59413a12f9ab35be958be.tar.gz App-ImapNotify-c66032630f0e4fc3f4b59413a12f9ab35be958be.tar.xz |
Reconnect when connection is lost
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/ImapNotify/Socket/SSL.pm')
-rw-r--r-- | lib/App/ImapNotify/Socket/SSL.pm | 20 |
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; } |