Пример #1
0
        public static DirectChannelToken32 Decode(BinaryReader reader)
        {
            var r = new DirectChannelToken32();

            r.Token32 = reader.ReadUInt32();
            return(r);
        }
Пример #2
0
        public InviteSession(LocalDrpPeer localDrpPeer)
        {
            _localDrpPeer = localDrpPeer;
            _localDrpPeer.CryptoLibrary.GenerateEcdh25519Keypair(out LocalInviteAckEcdhePrivateKey, out LocalInviteAckEcdhePublicKey);
            _localDrpPeer.CryptoLibrary.GenerateEcdh25519Keypair(out LocalDirectChannelEcdhePrivateKey, out LocalDirectChannelEcdhePublicKey);

            DirectChannelToken32 localDirectChannelToken32 = null;

            for (int i = 0; i < 100; i++)
            {
                localDirectChannelToken32 = new DirectChannelToken32 {
                    Token32 = (uint)localDrpPeer.Engine.InsecureRandom.Next()
                };
                var token16 = localDirectChannelToken32.Token16;
                if (localDrpPeer.Engine.InviteSessionsByToken16[token16] == null)
                {
                    localDrpPeer.Engine.InviteSessionsByToken16[token16] = this;
                    break;
                }
            }
            if (localDirectChannelToken32 == null)
            {
                throw new InsufficientResourcesException();
            }
            LocalDirectChannelToken32 = localDirectChannelToken32;
        }