SharpTox.Core.Tox.GetData C# (CSharp) Method

GetData() public method

Retrieves a ToxData object that contains the profile data of this Tox instance.
public GetData ( ) : ToxData
return ToxData
        public ToxData GetData()
        {
            ThrowIfDisposed();

            byte[] bytes = new byte[ToxFunctions.GetSaveDataSize(_tox)];
            ToxFunctions.GetSaveData(_tox, bytes);

            return new ToxData(bytes);
        }

Same methods

Tox::GetData ( ToxEncryptionKey key ) : ToxData

Usage Example

Example #1
0
        public void TestToxEncryptionLoad()
        {
            var tox1 = new Tox(ToxOptions.Default);
            tox1.Name = "Test";
            tox1.StatusMessage = "Hey";

            var key = new ToxEncryptionKey("heythisisatest");
            var data = tox1.GetData(key);

            Assert.IsNotNull(data, "Failed to encrypt the Tox data");
            Assert.IsTrue(data.IsEncrypted, "We encrypted the data, but toxencryptsave thinks we didn't");

            var tox2 = new Tox(ToxOptions.Default, ToxData.FromBytes(data.Bytes), key);

            if (tox2.Id != tox1.Id)
                Assert.Fail("Failed to load tox data correctly, tox id's don't match");

            if (tox2.Name != tox1.Name)
                Assert.Fail("Failed to load tox data correctly, names don't match");

            if (tox2.StatusMessage != tox1.StatusMessage)
                Assert.Fail("Failed to load tox data correctly, status messages don't match");

            tox1.Dispose();
            tox2.Dispose();
        }
All Usage Examples Of SharpTox.Core.Tox::GetData