| 1 | package Javonet::Core::Receiver::Receiver; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Config; | ||
| 5 | use File::Basename; | ||
| 6 | |||
| 7 | use Exporter qw(import); | ||
| 8 | our @EXPORT = qw(heart_beat send_command get_runtime_info); | ||
| 9 | |||
| 10 | my $perlLibDirJavonet; | ||
| 11 | my $perlLibDirDeps; | ||
| 12 | |||
| 13 | BEGIN { | ||
| 14 | my $thisFileDir = dirname(__FILE__); | ||
| 15 | $perlLibDirJavonet = "$thisFileDir/../../../"; | ||
| 16 | $perlLibDirDeps = "$thisFileDir/../../../../deps/lib/perl5" | ||
| 17 | } | ||
| 18 | |||
| 19 | use lib "$perlLibDirJavonet"; | ||
| 20 | use lib "$perlLibDirDeps"; | ||
| 21 | #use Nice::Try; Try-catch statement causes unhandler exception in c++ | ||
| 22 | use aliased 'Javonet::Core::Interpreter::Interpreter' => 'Interpreter'; | ||
| 23 | use aliased 'Javonet::Sdk::Core::RuntimeLogger' => 'RuntimeLogger'; | ||
| 24 | use aliased 'Javonet::Core::Exception::ExceptionSerializer' => 'ExceptionSerializer'; | ||
| 25 | use aliased 'Javonet::Sdk::Core::PerlCommand' => 'PerlCommand'; | ||
| 26 | use aliased 'Javonet::Sdk::Core::PerlCommandType' => 'Javonet::Sdk::Core::PerlCommandType'; | ||
| 27 | use aliased 'Javonet::Sdk::Core::RuntimeLib' => 'Javonet::Sdk::Core::RuntimeLib'; | ||
| 28 | use aliased 'Javonet::Core::Protocol::CommandSerializer' => 'CommandSerializer'; | ||
| 29 | #use aliased 'Javonet::Core::Exception::Exception' => 'Exception'; | ||
| 30 | |||
| 31 | |||
| 32 | sub heart_beat { | ||
| 33 | my ($class, $message_byte_array_ref) = @_; | ||
| 34 | my @response_byte_array = (49, 48); | ||
| 35 | return \@response_byte_array; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub send_command { | ||
| 39 | my ($class, $message_byte_array_ref) = @_; | ||
| 40 | my @message_byte_array = @$message_byte_array_ref; | ||
| 41 | my @response_byte_array; | ||
| 42 | # try { | ||
| 43 | @response_byte_array = Javonet::Core::Interpreter::Interpreter->process(\@message_byte_array); | ||
| 44 | # } | ||
| 45 | # catch ( $e ) { | ||
| 46 | # my $exception = Exception->new($e); | ||
| 47 | # my $exception_command = Javonet::Core::Exception::ExceptionSerializer->serialize($exception); | ||
| 48 | # @response_byte_array = CommandSerializer->serialize($exception_command, 0, 0, 0); | ||
| 49 | # }; | ||
| 50 | |||
| 51 | return \@response_byte_array; | ||
| 52 | |||
| 53 | |||
| 54 | } | ||
| 55 | |||
| 56 | sub get_runtime_info { | ||
| 57 | my ($class) = @_; | ||
| 58 | return RuntimeLogger->rl_get_runtime_info(); | ||
| 59 | } | ||
| 60 | |||
| 61 | 1; |