Пример #1
0
        static int DoRecord(string to, string file)
        {
            // Example cmd line: call [email protected]
            OpalMessageRef command = new OpalMessageRef();
            OpalMessageRef response;

            Console.WriteLine("Calling {0}", to);

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdSetUpCall);
            OpalParamSetUpCallRef m_callSetUp = command.GetCallSetUp();

            m_callSetUp.PartyB = to;
            if ((response = MySendCommand(command, "Could not make call")) == null)
            {
                return(0);
            }

            currentCallToken = response.GetCallSetUp().CallToken;

            Console.WriteLine("Recording {0}", file);

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdStartRecording);
            OpalParamRecordingRef m_recording = command.GetRecording();

            m_recording.CallToken = currentCallToken;
            m_recording.File      = file;
            m_recording.Channels  = 2;

            if ((response = MySendCommand(command, "Could not start recording")) == null)
            {
                return(0);
            }

            return(1);
        }
Пример #2
0
        static int DoPlay(string to, string file)
        {
            // Example cmd line: call [email protected]
            OpalMessageRef command = new OpalMessageRef();
            OpalMessageRef response;

            Console.WriteLine("Playing {0} to {1}", file, to);

            playScript = String.Format("ivr:<?xml version=\"1.0\"?><vxml version=\"1.0\"><form id=\"PlayFile\">" +
                                       "<audio src=\"{0}\"/></form></vxml>", file);

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdSetUpCall);
            OpalParamSetUpCallRef m_callSetUp = command.GetCallSetUp();

            m_callSetUp.PartyB = to;

            if ((response = MySendCommand(command, "Could not make call")) == null)
            {
                return(0);
            }

            currentCallToken = response.GetCallSetUp().CallToken;

            return(1);
        }
Пример #3
0
        static int DoRegister(string aor, string pwd)
        {
            // Example cmd line: register [email protected] secret
            OpalMessageRef command = new OpalMessageRef();
            OpalMessageRef response;

            Console.WriteLine("Registering {0}", aor);

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdRegistration);
            OpalParamRegistrationRef m_registrationInfo = command.GetRegistrationInfo();

            if (!aor.Contains(':'))
            {
                m_registrationInfo.Protocol   = "h323";
                m_registrationInfo.Identifier = aor;
            }
            else
            {
                m_registrationInfo.Protocol   = aor;
                m_registrationInfo.Identifier = aor.Substring(aor.IndexOf(':') + 1);
            }

            m_registrationInfo.Password   = pwd;
            m_registrationInfo.TimeToLive = 300;

            if ((response = MySendCommand(command, "Could not register endpoint")) == null)
            {
                return(0);
            }

            return(1);
        }
Пример #4
0
        static int DoCall(string from, string to)
        {
            // Example cmd line: call [email protected]
            OpalMessageRef command  = new OpalMessageRef();
            OpalMessageRef response = new OpalMessageRef();

            Console.WriteLine("Calling {0}", to);

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdSetUpCall);
            OpalParamSetUpCallRef m_callSetUp = command.GetCallSetUp();

            m_callSetUp.PartyA = from;
            m_callSetUp.PartyB = to;

            OpalParamProtocolRef overrides = new OpalParamProtocolRef(new Opal_API.OpalParamProtocol());

            overrides.DisplayName = "Test Calling Party";
            m_callSetUp.Overrides = overrides.Param;

            if ((response = MySendCommand(command, "Could not make call")) == null)
            {
                return(0);
            }

            m_callSetUp      = response.GetCallSetUp();
            currentCallToken = m_callSetUp.CallToken;

            return(1);
        }
Пример #5
0
        static int DoTransfer(string to)
        {
            // Example cmd line: transfer [email protected] [email protected]
            OpalMessageRef command = new OpalMessageRef();
            OpalMessageRef response;

            Console.WriteLine("Transferring to {0}", to);

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdTransferCall);
            OpalParamSetUpCallRef m_callSetup = command.GetCallSetUp();

            m_callSetup.PartyB    = to;
            m_callSetup.CallToken = currentCallToken;

            if ((response = MySendCommand(command, "Could not transfer call")) == null)
            {
                return(0);
            }

            return(1);
        }
Пример #6
0
        static int DoHold()
        {
            // Example cmd line: hold [email protected]
            OpalMessageRef command = new OpalMessageRef();
            OpalMessageRef response;

            Console.WriteLine("Hold");

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdHoldCall);
            command.SetCallToken(currentCallToken);

            if ((response = MySendCommand(command, "Could not hold call")) == null)
            {
                return(0);
            }

            heldCallToken    = currentCallToken;
            currentCallToken = null;

            return(1);
        }
Пример #7
0
        static int DoMute(bool on)
        {
            // Example cmd line: mute [email protected]
            OpalMessageRef command  = new OpalMessageRef();
            OpalMessageRef response = new OpalMessageRef();

            Console.WriteLine("Mute {0}", on ? "on" : "off");

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdMediaStream);
            OpalStatusMediaStreamRef m_mediaStream = command.GetMediaStream();

            m_mediaStream.CallToken = currentCallToken;
            m_mediaStream.Type      = "audio out";
            m_mediaStream.State     = on ? Opal_API.OpalMediaStates.OpalMediaStatePause : Opal_API.OpalMediaStates.OpalMediaStateResume;
            if ((response = MySendCommand(command, "Could not mute call")) == null)
            {
                return(0);
            }

            return(1);
        }
Пример #8
0
        static int DoSubscribe(string package, string aor, string from)
        {
            // Example cmd line: subscribe "dialog;sla;ma" [email protected] [email protected]
            OpalMessageRef command = new OpalMessageRef();
            OpalMessageRef response;

            Console.WriteLine("Susbcribing {0}", aor);

            command.SetMessageType(Opal_API.OpalMessageType.OpalCmdRegistration);
            OpalParamRegistrationRef m_registrationInfo = command.GetRegistrationInfo();

            m_registrationInfo.Protocol     = "sip";
            m_registrationInfo.Identifier   = aor;
            m_registrationInfo.HostName     = from;
            m_registrationInfo.EventPackage = package;
            m_registrationInfo.TimeToLive   = 300;

            if ((response = MySendCommand(command, "Could not subscribe")) == null)
            {
                return(0);
            }

            return(1);
        }