},
}
},
+ (CHECKOUT_RESP) => {
+ name => "Checkout Response",
+ protocol => {
+ 2 => {
+ template => "A1A1A1A1A18",
+ template_len => 22,
+ fields => [(FID_INST_ID),(FID_PATRON_ID),
+ (FID_ITEM_ID),(FID_TITLE_ID),
+ (FID_DUE_DATE),(FID_FEE_TYPE),
+ (FID_SECURITY_INHIBIT),(FID_CURRENCY),
+ (FID_FEE_AMT),(FID_MEDIA_TYPE),
+ (FID_ITEM_PROPS),(FID_SCREEN_MSG),
+ (FID_PRINT_LINE)],
+ },
+
+ }
+ },
+
+
(CHECKIN) => {
name => "Checkin",
handler => \&handle_checkin,
}
}
},
+ (CHECKIN_RESP) => {
+ name => "Checkin Response",
+ protocol => {
+ 2 => {
+ template => "A1A1A1A1A18",
+ template_len => 22,
+ fields => [(FID_INST_ID),(FID_ITEM_ID),(FID_PERM_LOCN),(FID_TITLE_ID),
+ (FID_SORT_BIN),(FID_PATRON_ID),(FID_MEDIA_TYPE),(FID_ITEM_PROPS),
+ (FID_SCREEN_MSG),(FID_PRINT_LINE)],
+ }
+ }
+ },
(BLOCK_PATRON) => {
name => "Block Patron",
handler => \&handle_block_patron,
}
}
},
+
+ (LOGIN_RESP) => {
+ name => "Login Response",
+ protocol => {
+ 2 => {
+ template => "A",
+ template_len => 1,
+ fields => [],
+ }
+ }
+
+ },
+
(PATRON_INFO) => {
name => "Patron Info",
handler => \&handle_patron_info,
}
}
},
+
+ (PATRON_INFO_RESP) => {
+ name => "patron_info_resp",
+ protocol => {
+ 2 => {
+ template => "A14A3A18A4A4A4A4A4A4",
+ template_len => 59,
+ fields => [(FID_INST_ID), (FID_PATRON_ID), (FID_PERSONAL_NAME), (FID_HOLD_ITEMS_LMT), (FID_OVERDUE_ITEMS_LMT), (FID_CHARGED_ITEMS_LMT), (FID_VALID_PATRON), (FID_VALID_PATRON_PWD), (FID_CURRENCY), (FID_FEE_AMT), (FID_FEE_LMT), (FID_HOLD_ITEMS), (FID_OVERDUE_ITEMS), (FID_CHARGED_ITEMS), (FID_FINE_ITEMS), (FID_RECALL_ITEMS), (FID_UNAVAILABLE_HOLD_ITEMS), (FID_EMAIL), (FID_HOME_PHONE), (FID_SCREEN_MSG), (FID_PRINT_LINE)],
+ }
+ }
+
+ },
+
+
(END_PATRON_SESSION) => {
name => "End Patron Session",
handler => \&handle_end_patron_session,
}
}
},
+ (ITEM_INFO_RESP) =>{
+ name => "Item Information Response",
+ protocol => {
+ 2 => {
+ template => "A2A2A2A18",
+ template_len => 24,
+ fields => [(FID_HOLD_QUEUE_LEN),(FID_DUE_DATE),(FID_RECALL_DATE),(FID_HOLD_PICKUP_DATE),(FID_ITEM_ID),(FID_TITLE_ID),
+ (FID_OWNER),(FID_CURRENCY),(FID_FEE_AMT),(FID_MEDIA_TYPE),(FID_PERM_LOCN),(FID_CURRENT_LOCN),(FID_ITEM_PROPS),(FID_SCREEN_MSG),(FID_PRINT_LINE)],
+ }
+ }
+ },
+
(ITEM_STATUS_UPDATE) => {
name => "Item Status Update",
handler => \&handle_item_status_update,
}
}
},
+ (HOLD_RESP) => {
+ name => "Hold Response",
+ protocol => {
+ 2 => {
+ template => "AAA18",
+ template_len => 20,
+ fields => [(FID_EXPIRATION), (FID_QUEUE_POS),(FID_PICKUP_LOCN),(FID_INST_ID),(FID_PATRON_ID),(FID_ITEM_ID),(FID_TITLE_ID),(FID_SCREEN_MSG),(FID_PRINT_LINE)],
+ }
+ }
+ },
+
+
(RENEW) => {
name => "Renew",
handler => \&handle_renew,
}
sub new {
- my ($class, $msg, $seqno) = @_;
+ my ($class, $msg, $seqno, $is_client) = @_;
my $self = {};
my $msgtag = substr($msg, 0, 2);
bless $self, $class;
$self->{seqno} = $seqno;
+ $self->{is_client} = $is_client;
$self->_initialize(substr($msg,2), $handlers{$msgtag});
return($self);
syslog("LOG_WARNING",
"Unsupported field '%s' in %s message '%s'",
$fn, $self->{name}, $msg);
+
} elsif (defined($self->{fields}->{$fn})) {
- syslog("LOG_WARNING",
- "Duplicate field '%s' (previous value '%s') in %s message '%s'",
- $fn, $self->{fields}->{$fn}, $self->{name}, $msg);
+
+ if ($self->{is_client}) {
+ # in client mode, it's not uncommon to receive repeating
+ # fields of data. E.g. list of hold items
+
+ $self->{fields}->{$fn} = [$self->{fields}->{$fn}]
+ unless ref $self->{fields}->{$fn} eq 'ARRAY';
+
+ push (@{$self->{fields}->{$fn}}, substr($field, 2));
+
+ } else {
+
+ #syslog("LOG_WARNING",
+ #"Duplicate field '%s' (previous value '%s') in %s message '%s'",
+ #$fn, $self->{fields}->{$fn}, $self->{name}, $msg);
+ }
+
} else {
$self->{fields}->{$fn} = substr($field, 2);
}