source: apps/sam/perl/Net/SAM/DatagramSession.pm @ 6003b29

Last change on this file since 6003b29 was 6003b29, checked in by zzz <zzz@…>, 17 years ago

Preliminary checkin of (mostly useless) Net::SAM perl module.

Net::SAM::StreamSession? is currently unimplemented.
Net::Sam::[Datagram|Raw]Session block when they shouldn't and are buggy.

  • Property mode set to 100644
File size: 914 bytes
Line 
1#!/usr/bin/perl
2
3package Net::SAM::DatagramSession;
4
5use Net::SAM;
6
7@ISA = ("Net::SAM");
8
9sub new {
10    my ($class) = shift;
11    my ($dest , $direction, $options) = shift; 
12
13    my $self = $class->SUPER::new(@_);
14
15    $self->SUPER::send("SESSION CREATE STYLE=DATAGRAM DESTINATION=$dest DIRECTION=$direction $options\n");
16
17    undef ${*$self}->{RESULT};
18
19    while ( ! ${*$self}->{RESULT} ) {
20        $self->readprocess() || return undef;
21           
22    }
23
24    if ( ${*$self}->{RESULT} == "OK" ) {
25        return $self;
26    } else {
27        return undef; # sorry.
28    }
29}
30
31sub send {
32    my $self = shift;
33    my $destination = shift;
34    my $message = shift;
35    my $size = length($message);
36    $self->SUPER::send("DATAGRAM SEND DESTINATION=$destination SIZE=$size\n$message");
37}
38
39sub receive {
40    my $self = shift;
41
42    # Shift one off the fifo array. Returns undef if none wait.
43    return shift @{ $self->{incomingdatagram} };
44}
45
46
47
481;
Note: See TracBrowser for help on using the repository browser.