FriendExists() public method

Checks if there exists a friend with given friendNumber.
public FriendExists ( int friendNumber ) : bool
friendNumber int The friend number to check.
return bool
示例#1
0
        public void TestToxFriendRequest()
        {
            var options = new ToxOptions(true, true);
            var tox1 = new Tox(options);
            var tox2 = new Tox(options);
            var error = ToxErrorFriendAdd.Ok;
            string message = "Hey, this is a test friend request.";
            bool testFinished = false;

            tox1.AddFriend(tox2.Id, message, out error);
            if (error != ToxErrorFriendAdd.Ok)
                Assert.Fail("Failed to add friend: {0}", error);

            tox2.OnFriendRequestReceived += (sender, args) =>
            {
                if (args.Message != message)
                    Assert.Fail("Message received in the friend request is not the same as the one that was sent");

                tox2.AddFriendNoRequest(args.PublicKey, out error);
                if (error != ToxErrorFriendAdd.Ok)
                    Assert.Fail("Failed to add friend (no request): {0}", error);

                if (!tox2.FriendExists(0))
                    Assert.Fail("Friend doesn't exist according to core");

                testFinished = true;
            };

            while (!testFinished && tox1.GetFriendConnectionStatus(0) == ToxConnectionStatus.None)
            {
                int time1 = tox1.Iterate();
                int time2 = tox2.Iterate();

                Thread.Sleep(Math.Min(time1, time2));
            }

            tox1.Dispose();
            tox2.Dispose();
        }