source: apps/sam/perl/Net/SAM/RawSession.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: 878 bytes
Line 
1#!/usr/bin/perl
2
3package Net::SAM::RawSession;
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->send("SESSION CREATE STYLE=RAW DESTINATION=$dest DIRECTION=$direction $options\n");
16
17    undef $self->{result};
18    while ( ! $self->{RESULT} ) {
19        $self->readprocess();
20    }
21
22    if ( $self->{RESULT} == "OK" ) {
23        return $self;
24    } else {
25        return 0; # sorry.
26    }
27}
28
29sub send {
30    my $self = shift;
31    my $destination = shift;
32    my $message = shift;
33    my $samsock = $self->{samsock};
34    my $size = length($message);
35    print $samsock "RAW SEND DESTINATION=$destination SIZE=$size\n$message";
36}
37
38sub receive {
39    my $self = shift;
40
41    # Shift one off the fifo array. Returns undef if none wait.
42    return shift @{ $self->{incomingraw} };
43}
44
451;
Note: See TracBrowser for help on using the repository browser.