public HybridConnection(HybridConnectionRole role, Microsoft.ServiceBus.Channels.IConnection connection, IDisposable directConnect, int asyncReadBufferSize) { if (connection == null) { throw Fx.Exception.ArgumentNull("connection"); } this.connectionState = HybridConnectionState.Relayed; this.closeState = HybridConnection.CloseState.Open; this.exceptionEventType = TraceEventType.Error; Microsoft.ServiceBus.Channels.IConnection connection1 = connection; Microsoft.ServiceBus.Channels.IConnection connection2 = connection1; this.writeConnection = connection1; this.readConnection = connection2; this.asyncReadBufferSize = asyncReadBufferSize; this.Activity = connection.Activity; this.role = role; this.readConnectionQueue = new Queue <Microsoft.ServiceBus.Channels.IConnection>(); this.writeConnectionQueue = new Queue <Microsoft.ServiceBus.Channels.IConnection>(); this.directConnect = directConnect; if (connection.AsyncReadBufferSize != asyncReadBufferSize) { throw new InvalidOperationException(SRClient.InvalidBufferSize); } }
public void EnqueueConnection(Microsoft.ServiceBus.Channels.IConnection connection) { lock (this.ThisLock) { if (this.closeState != HybridConnection.CloseState.Closed) { if (connection.AsyncReadBufferSize != this.asyncReadBufferSize) { throw new InvalidOperationException(SRClient.InvalidBufferSize); } this.readConnectionQueue.Enqueue(connection); if (this.role == HybridConnectionRole.Initiator) { this.writeConnectionQueue.Enqueue(connection); } this.connectionState = HybridConnectionState.Direct; this.OnConnectionStateChanged(); } else { connection.Close(TimeSpan.FromSeconds(1)); } } }
public HybridConnectionStateChangedArgs(HybridConnectionState state) { this.state = state; }