| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF.Channels |
| | | 7 | | { |
| | | 8 | | internal sealed class ConnectionReference |
| | | 9 | | { |
| | | 10 | | private readonly long _id; |
| | | 11 | | private readonly WeakReference<NamedPipeConnection> _weakReference; |
| | | 12 | | private readonly TransportConnectionManager _transportConnectionManager; |
| | | 13 | | |
| | 0 | 14 | | public ConnectionReference(long id, NamedPipeConnection connection, TransportConnectionManager transportConnecti |
| | | 15 | | { |
| | 0 | 16 | | _id = id; |
| | | 17 | | |
| | 0 | 18 | | _weakReference = new WeakReference<NamedPipeConnection>(connection); |
| | 0 | 19 | | ConnectionId = connection.ConnectionContext.ConnectionId; |
| | | 20 | | |
| | 0 | 21 | | _transportConnectionManager = transportConnectionManager; |
| | 0 | 22 | | } |
| | | 23 | | |
| | 0 | 24 | | public string ConnectionId { get; } |
| | | 25 | | |
| | | 26 | | public bool TryGetConnection(out NamedPipeConnection connection) |
| | | 27 | | { |
| | 0 | 28 | | return _weakReference.TryGetTarget(out connection); |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | public void StopTranssportTracking() |
| | | 32 | | { |
| | 0 | 33 | | _transportConnectionManager.StopTracking(_id); |
| | 0 | 34 | | } |
| | | 35 | | } |
| | | 36 | | } |