Пример #1
0
        public void TestToxAvCallAndAnswer()
        {
            var options = new ToxOptions(true, true);
            var tox1    = new Tox(options);
            var tox2    = new Tox(options);

            var toxAv1 = new ToxAv(tox1);
            var toxAv2 = new ToxAv(tox2);

            bool testFinished = false;

            Task.Run(async() =>
            {
                while (!testFinished)
                {
                    int time1 = tox1.Iterate();
                    int time2 = tox2.Iterate();

                    await Task.Delay(Math.Min(time1, time2));
                }
            });

            tox1.AddFriend(tox2.Id, "hey");
            tox2.AddFriend(tox1.Id, "hey");

            while (tox1.GetFriendConnectionStatus(0) == ToxConnectionStatus.None)
            {
                Thread.Sleep(10);
            }

            bool answered = false;

            toxAv1.Call(0, 48, 30000);

            toxAv2.OnCallRequestReceived += (sender, e) =>
            {
                var  error2  = ToxAvErrorAnswer.Ok;
                bool result2 = toxAv2.Answer(e.FriendNumber, 48, 30000, out error2);
            };

            toxAv1.OnCallStateChanged += (sender, e) =>
            {
                answered = true;
            };

            while (!answered)
            {
                Thread.Sleep(10);
            }

            testFinished = true;
            toxAv1.Dispose();
            toxAv2.Dispose();
            tox1.Dispose();
            tox2.Dispose();
        }
Пример #2
0
        public bool Call(int friendNumber, int audioBitrate, int videoBitrate)
        {
            if (_friendInCall != -1)
            {
                return(false);
            }

            _friendInCall = friendNumber;

            ToxAvErrorCall error;
            var            retVal = _toxAv.Call(friendNumber, audioBitrate, videoBitrate, out error);

            ToxErrorViewModel.Instance.RelayError(error);
            return(retVal);
        }
Пример #3
0
        public void Init()
        {
            var options = new ToxOptions(true, true);

            _tox1 = new Tox(options);
            _tox2 = new Tox(options);

            _toxAv1 = new ToxAv(_tox1);
            _toxAv2 = new ToxAv(_tox2);

            _tox1.AddFriend(_tox2.Id, "hey");
            _tox2.AddFriend(_tox1.Id, "hey");

            while (_tox1.GetFriendConnectionStatus(0) == ToxConnectionStatus.None)
            {
                DoIterate();
            }

            bool answered = false;

            _toxAv1.Call(0, 48, 3000);

            _toxAv2.OnCallRequestReceived += (sender, e) =>
            {
                var  error2  = ToxAvErrorAnswer.Ok;
                bool result2 = _toxAv2.Answer(e.FriendNumber, 48, 3000, out error2);
            };

            _toxAv1.OnCallStateChanged += (sender, e) =>
            {
                answered = true;
            };

            while (!answered)
            {
                DoIterate();
            }
        }
Пример #4
0
 public void Call(int current_number, ToxAvCodecSettings settings, int ringing_seconds)
 {
     toxav.Call(current_number, settings, ringing_seconds, out CallIndex);
 }