Написал sppr для конференций без пинов и лидеров - суть, голосовые комнаты. Возможно, кому то пригодится.

От: Sergey Kronshtadtov <CGatePro_at_mx_ru>
Дата: Fri 18 Dec 2009 - 20:22:47 MSK


Найденные ошибки приветствуются.

Суть сервиса:
Люди звонят по определенному номеру голосовой комнаты, представляются и попадают в конференцию, после чего разговаривают между собой. Из минусов - нет приватности и доступ снаружи лучше не давать. Из плюсов - проще уже некуда и есть шанс что люди с гуманитарным или бизнесовым складом ума смогут воспользоваться сервисом. Есть кое-какое управление во время разговора. Оно нехитрое и, думаю, понятно из кода.

Комнаты вызываются из роутера записями вида:

n:s:<2801@*> = svkconferenceroom{000001}#pbx@tn.arm.ru
n:s:<2802@*> = svkconferenceroom{000002}#pbx@tn.arm.ru
n:s:<2803@*> = svkconferenceroom{000003}#pbx@tn.arm.ru

Собственно, файл svkconferenceroom.sppr:



procedure playMenu (promptFile, optionValue) external; procedure playSine (freq, msec) external;

entry Main is

if AcceptCall () != null then stop; end if;

thePassword = Vars().startParameter[0];

parameter = NewDictionary ();

parameter.isOpen = true;

void (CreateMeeting (null, thePassword, parameter));

isNew = true;

PlayFile ("ConferenceEntry");

if ActivateMeeting (null, thePassword) != null then

    isNew = false;

    meetingInfo = FindMeeting (null, thePassword);

    if meetingInfo != null then

        void (SendEvent (meetingInfo.id, "getPartyIntros", null));

        input = readInput (30);

        if IsDictionary (input) and then input.what == "partyIntros" then

PlayFile ("ConferenceMembers");
index = 0;
while index < length (input.parameter)
loop
playSine (2000, 50);
Play (input.parameter.(input.parameter[index])); index = index + 1;
end loop;
playSine (2000, 500);

        end if;

    end if;

else

    PlayFile ("ConnectingNow");
end if;

if RemoteAuthentication () != null then

    Intro = ReadSiteFile ("~" + RemoteAuthentication () + "/myname.wav"); end if;

if Intro == null then

    PlayFile ("IntroduceYourself");
    PlayFile ("FinishByPound");
    PlayFile ("RecordingBeep");

    Intro = record (5);
end if;

ClearDTMF ();

// playMenu ("ToMuteYourLine", "*6");
// playMenu ("ToUnmute", "*7");
// playMenu ("ToDisconnect", "#");

ClearDTMF();

PlayFile ("JoiningConference");

if !isNew then

    meetingInfo = FindMeeting (null, thePassword);     if meetingInfo != null then

void (SendEvent (meetingInfo.id, "partyName", Intro)); void (SendEvent (meetingInfo.id, "partyAddr", SIPURIToEmail (RemoteURI ())));

if StartBridge (meetingInfo.id) != null then

    PlayFile ("Failure");
    return;
end if;

loop

input = readInput (30);

if input == "*" then

    input = readInput (5);
    if input == null then input = "*";
    elif IsDigit (input) then input = "*" + input;     end if;
end if;

exitif input != null and then (input == "#" or not IsString (input));

if input == "*5" then

    void (SendEvent (meetingInfo.id, "playPartyList", null)); elif input == "*6" then

    void (SendEvent (meetingInfo.id, "mute", true)); elif input == "*7" then

    void (SendEvent (meetingInfo.id, "mute", false)); end if;

end loop;

if IsDisconnectEvent (input) then return; end if;

if not IsBreakBridgeEvent (input) then void (BreakBridge()); end if;

PlayFile ("DisconnectedConference");

    else

        PlayFile ("Failure");
    end if;

    return;

else

    meetingInfo = FindMeeting (null, thePassword);     if meetingInfo != null then

void (SendEvent (meetingInfo.id, "partyName", Intro)); void (SendEvent (meetingInfo.id, "partyAddr", SIPURIToEmail (RemoteURI ())));

playBeeps = false;
playMusic = true;

partyIntros = NewDictionary ();
partyAddrs = NewDictionary ();

loop

if playMusic then

    PlayFileInLoop ("HoldMusic", 300000);     input = ReadInput (0);
else

    input = ReadInput (60);
end if;

if input == "*" then

    input = ReadInput (10);
    if IsString (input) then input = "*" + input; end if; end if;

exitif IsDisconnectEvent (input) or else input == "#";

if IsStartBridgeEvent (input) then

    if AttachMixer (input) == null then

        ClearDTMF (); Play (partyIntros.(String (input.sender))); PlayFile ("JoinedConference");

        playMusic = false;
    else

        partyIntros.(String (input.sender)) = null;
        partyAddrs.(String (input.sender)) = null;
    end if;

elif IsBreakBridgeEvent (input) then

    ClearDTMF (); Play (partyIntros.(String (input.sender))); PlayFile ("LeftConference");

    partyIntros.(String (input.sender)) = null;     partyAddrs.(String (input.sender)) = null;     if Length (partyIntros) <= 1 then playMusic = true; end if;

elif IsDictionary (input) and then input.what == "partyName" then

    partyIntros.(String (input.sender)) = input.parameter;

elif IsDictionary (input) and then input.what == "partyAddr" then

    partyAddrs.(String (input.sender)) = input.parameter;

elif IsDictionary (input) and then input.what == "getPartyList" then

    void (SendEvent (input.sender, "partyList", ObjectToString (partyAddrs)));

elif IsDictionary (input) and then input.what == "getPartyIntros" then

    void (SendEvent (input.sender, "partyIntros", partyIntros));

elif IsDictionary (input) and then input.what == "playPartyList" then

    PlayFile ("ConferenceMembers");
    index = 0;
    while index < length (partyIntros)
    loop
    playSine (2000, 50);
    Play (partyIntros.(partyIntros[index]));     index = index + 1;
    end loop;
    playSine (2000, 500);

elif IsDictionary (input) and then input.what == "mute" then

    muteMixer (input.sender, input.parameter);

elif IsDictionary (input) then

    SysLog ("unexpected event: " + input.what);

elif input == "*1" then

    void (MixerThreshold ((MixerThreshold (null) + 3) * 3 / 2));

elif input == "*2" then

    void (MixerThreshold (MixerThreshold (null) * 2 / 3));

elif input == "*3" then

    void (MixerDelay (MixerDelay (null) + 50));

elif input == "*4" then

    void (MixerDelay (MixerDelay (null) - 50));

elif input == "*5" then

    void (SendEvent (meetingInfo.id, "playPartyList", null));

elif input == "*6" then

    MuteMixer (null, true);

elif input == "*7" then

    MuteMixer (null, false);

elif input == "*8" then

    playMusic = not playMusic;

elif input == "*9" then

    playBeeps = not playBeeps;

elif input == null then

    if playBeeps then playSine (3000, 200); end if;

else

    playSine (300,100); playSine (500,100);

end if;

end loop;

void (DetachMixer (null));
void (DeactivateMeeting (null, thePassword)); PlayFile ("DisconnectedConference");

    else

        PlayFile ("Failure");
    end if;

    return;

end if;

end entry;


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4693 (20091216) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com Получено Fri Dec 18 17:20:59 2009

Этот архив был сгенерирован hypermail 2.1.8 : Fri 24 Apr 2015 - 16:16:37 MSK