Example #1
0
		private void OnDataSending( InProcDataSendingEventArgs e )
		{
			var handler = this.DataSending;
			if ( handler != null )
			{
				handler( this, e );
			}
		}
Example #2
0
        private void OnDataSending(InProcDataSendingEventArgs e)
        {
            var handler = this.DataSending;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Example #3
0
        protected sealed override void SendCore(ClientRequestContext context)
        {
            var destination = this._destination;

            if (destination == null)
            {
                throw new ObjectDisposedException(this.ToString());
            }

            var data          = context.BufferList.SelectMany(segment => segment.Array.Skip(segment.Offset).Take(segment.Count)).ToArray();
            var dataEventArgs = new InProcDataSendingEventArgs()
            {
                Data = data
            };

            this.OnDataSending(dataEventArgs);

            if (Interlocked.CompareExchange(ref this._canSend, 0, 0) != 0)
            {
                destination.FeedData(dataEventArgs.Data);
                this.OnMessageSent(new InProcMessageSentEventArgs(context));
            }
            else
            {
                context.SocketError = SocketError.OperationAborted;
            }

            using (var dummySocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {
                if (!this.HandleSocketError(dummySocket, context))
                {
                    return;
                }
            }

            this.OnSent(context);
        }
Example #4
0
		protected sealed override void SendCore( ClientRequestContext context )
		{
			var destination = this._destination;
			if ( destination == null )
			{
				throw new ObjectDisposedException( this.ToString() );
			}

			var data = context.BufferList.SelectMany( segment => segment.Array.Skip( segment.Offset ).Take( segment.Count ) ).ToArray();
			var dataEventArgs = new InProcDataSendingEventArgs() { Data = data };
			this.OnDataSending( dataEventArgs );

			if ( Interlocked.CompareExchange( ref this._canSend, 0, 0 ) != 0 )
			{
				destination.FeedData( dataEventArgs.Data );
				this.OnMessageSent( new InProcMessageSentEventArgs( context ) );
			}
			else
			{
				context.SocketError = SocketError.OperationAborted;
			}

			using ( var dummySocket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ) )
			{
				if ( !this.HandleSocketError( dummySocket, context ) )
				{
					return;
				}
			}

			this.OnSent( context );
		}
Example #5
0
		private static void EmulateSocketError( object sender, InProcDataSendingEventArgs e )
		{
			throw new SocketException( ( int )SocketError.ConnectionReset );
		}