summaryrefslogtreecommitdiffstats
path: root/lib/App/ImapNotify/Socket/SSL.pm
blob: 2654cdcd09023ef85a610dc2657bae0da6f6fe0c (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
35
36
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) {
	my $self = {};
	$self->{config} = {
		host => $host,
		port => $port,
	};
	bless $self, $class;
	return $self;
}

method reconnect() {
	$self->{sock} = IO::Socket::SSL->new("$self->{config}->{host}:$self->{config}->{port}");
}

method readline() {
	return CORE::readline $self->{sock};
}

method writeline($line) {
	print {$self->{sock}} $line;
}


1;

__END__