# $Id: BridgeViewSession.pm,v 1.1 2001/10/30 05:01:49 swick Exp $

package BridgeViewSession;
use Session;
use Conference;
use strict;

@BridgeViewSession::ISA = qw( Session );

sub version			# BV.VER
{
    # Version
    my ($self, $version) = @_;
    $self->trace( "BridgeViewSession ", $self->{_id}, " version $version" );
}

sub conferenceList		# BV.B.ACL
{
    # BRIDGEID~M~N~CONFCOUNT[~CONFID~CONFNAME~CONFKEY~GROUPKEY]
    my ($self, $bridge, $msgNum, $msgCount, $confCount, @rest) = @_;
    for (my $conf = 0; $conf < $confCount; $conf++) {
	my $i = $conf*4;
	my $confID = $rest[$i];
	my $confName = $rest[$i+1];
	$self->trace( "Conf $confID Name $confName" );
	Conference->new($bridge, $confID, $confName);
	Connection->request("LS.CS~ACV~$bridge~$confID");
    }
}

sub conferenceAdded		# BV.B.AC.ADD
{
    # BRIDGEID~CONFID~CONFNAME~CONFKEY~GROUPKEY
    my ($self, $bridge, $confID, $confName) = @_;
    Conference->new($bridge, $confID, $confName);
    Connection->request("LS.CS~ACV~$bridge~$confID");
}

sub conferenceDeleted		# BV.B.AC.DEL
{
    # BRIDGEID~CONFID
    my ($self, $bridge, $confID) = @_;
    Conference->delete($bridge, $confID);
}

sub conferenceChanged		# BV.B.AC.MOD
{
    # BRIDGEID~CONFID~CONFNAME~CONFKEY~GROUPKEY
    my ($self, $bridge, $confID, $confName) = @_;
    Conference->change($bridge, $confID, $confName);
}

sub new
{
    my ($proto, $conn, $id) = @_;
    my $class = ref($proto) || $proto;

    my $self = $class->SUPER::new($conn, $id);

    bless ($self, $class);

    $self->trace( "Session $id is a BridgeViewSession" );

    $self->{handler}->{'BV.VER'} = \&version;
    $self->{handler}->{'BV.B.ACL'} = \&conferenceList;
    $self->{handler}->{'BV.B.AC.ADD'} = \&conferenceAdded;
    $self->{handler}->{'BV.B.AC.DEL'} = \&conferenceDeleted;
    $self->{handler}->{'BV.B.AC.MOD'} = \&conferenceChanged;
    return $self;
}

1;
