Exemplo n.º 1
0
        private void CheckCertificateRevocationListAsync(object state)
        {
            SecureChannelStream stream = null;

            try
            {
                stream = state as SecureChannelStream;

                stream.RemotePeerCertificate.VerifyRevocationList();
            }
            catch (InvalidCertificateException ex)
            {
                if (stream != null)
                {
                    try
                    {
                        stream.Dispose();
                    }
                    catch
                    { }
                }

                VirtualPeerHasRevokedCertificate(this, ex);
            }
            catch
            { }
        }
Exemplo n.º 2
0
            private void ReadPacketAsync(object state)
            {
                SecureChannelStream stream = state as SecureChannelStream;

                try
                {
                    byte[]       buffer = new byte[MAX_BUFFER_SIZE];
                    MemoryStream mS     = new MemoryStream(buffer);
                    int          dataLength;

                    while (true)
                    {
                        OffsetStream.StreamRead(stream, buffer, 0, 2);
                        dataLength = BitConverter.ToUInt16(buffer, 0) + 1;

                        mS.SetLength(dataLength);
                        mS.Position = 0;

                        OffsetStream.StreamRead(stream, buffer, 0, dataLength);

                        try
                        {
                            PacketReceived(this, mS, stream.RemotePeerEP);
                        }
                        catch
                        { }
                    }
                }
                catch (SecureChannelException ex)
                {
                    if (_network.VirtualPeerSecureChannelException != null)
                    {
                        _network.VirtualPeerSecureChannelException(_network, ex);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Write("VirtualPeer.ReadPacketAsync", ex);
                }
                finally
                {
                    int totalStreamsAvailable;

                    lock (_streamList)
                    {
                        _streamList.Remove(stream);
                        totalStreamsAvailable = _streamList.Count;
                    }

                    lock (_readThreadList)
                    {
                        _readThreadList.Remove(Thread.CurrentThread);
                    }

                    if (!_disposing)
                    {
                        lock (this)
                        {
                            if (totalStreamsAvailable == 0)
                            {
                                _isOnline = false;
                            }

                            if (StreamStateChanged != null)
                            {
                                StreamStateChanged(this, EventArgs.Empty);
                            }
                        }
                    }

                    stream.Dispose();
                }
            }