From 50a37d8812c95c60203b0102db91f0c080d4d93b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 17 Jul 2018 15:26:40 +0200 Subject: Initial port of single file script Signed-off-by: Florian Pritz --- lib/App/ImapNotify/Socket/SSL.pm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/App/ImapNotify/Socket/SSL.pm (limited to 'lib/App/ImapNotify/Socket/SSL.pm') diff --git a/lib/App/ImapNotify/Socket/SSL.pm b/lib/App/ImapNotify/Socket/SSL.pm new file mode 100644 index 0000000..18d7ffa --- /dev/null +++ b/lib/App/ImapNotify/Socket/SSL.pm @@ -0,0 +1,34 @@ +package App::ImapNotify::Socket::SSL; +use v5.24; +use strict; +use warnings; + +use autodie; +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 = {}) { + my $self = {}; + bless $self, $class; + $self->{deps} = $deps; + return $self; +} + +method readline() { + return CORE::readline $self->{deps}->{sock}; +} + +method writeline($line) { + print {$self->{deps}->{sock}} $line; +} + + +1; + +__END__ -- cgit v1.2.3-24-g4f1b