summaryrefslogtreecommitdiffstats
path: root/lib/App/ImapNotify/Socket/SSL.pm
blob: 18d7ffaf73bdfe04d84d08604a8b8ac81c04fd4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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__