/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
namespace Apache.NMS.WCF
{
///
/// Server-side implementation of the sessionless one-way channel.
///
public class NmsInputChannel : NmsInputQueueChannelBase, IInputChannel
{
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The factory that was used to create the channel.
/// The local address of the channel.
internal NmsInputChannel(ChannelListenerBase factory, EndpointAddress localAddress)
: base(factory, localAddress)
{
}
#endregion
#region Receive
///
/// Begins an asynchronous operation to receive a message that has a state object associated with it.
///
/// The delegate that receives the notification of the asynchronous operation completion.
/// An object, specified by the application, that contains state information associated with the asynchronous operation.
///
/// The that references the asynchronous message reception.
///
public IAsyncResult BeginReceive(AsyncCallback callback, object state)
{
return BeginReceive(DefaultReceiveTimeout, callback, state);
}
///
/// Begins an asynchronous operation to receive a message that has a specified time out and state object associated with it.
///
/// The that specifies the interval of time to wait for a message to become available.
/// The delegate that receives the notification of the asynchronous operation completion.
/// An object, specified by the application, that contains state information associated with the asynchronous operation.
///
/// The that references the asynchronous receive operation.
///
/// The specified is exceeded before the operation is completed.
/// The timeout specified is less than zero.
public IAsyncResult BeginReceive(TimeSpan timeout, AsyncCallback callback, object state)
{
return BeginDequeue(timeout, callback, state);
}
///
/// Completes an asynchronous operation to receive a message.
///
/// The returned by a call to one of the System.ServiceModel.Channels.IInputChannel.BeginReceive methods.
///
/// The received.
///
public Message EndReceive(IAsyncResult result)
{
return EndDequeue(result);
}
///
/// Returns the message received, if one is available. If a message is not available, blocks for a default interval of time.
///
///
/// The received.
///
public Message Receive()
{
return Receive(DefaultReceiveTimeout);
}
///
/// Returns the message received, if one is available. If a message is not available, blocks for a specified interval of time.
///
/// The that specifies how long the receive operation has to complete before timing out and throwing a .
///
/// The received.
///
/// The specified is exceeded before the operation is completed.
/// The timeout specified is less than zero.
public Message Receive(TimeSpan timeout)
{
return this.Dequeue(timeout);
}
#endregion
#region TryReceive
///
/// Begins an asynchronous operation to receive a message that has a specified time out and state object associated with it.
///
/// The that specifies the interval of time to wait for a message to become available.
/// The delegate that receives the notification of the asynchronous operation completion.
/// An object, specified by the application, that contains state information associated with the asynchronous operation.
///
/// The that references the asynchronous receive operation.
///
/// The specified is exceeded before the operation is completed.
/// The timeout specified is less than zero.
public IAsyncResult BeginTryReceive(TimeSpan timeout, AsyncCallback callback, object state)
{
return BeginDequeue(timeout, callback, state);
}
///
/// Completes the specified asynchronous operation to receive a message.
///
/// The returned by a call to the method.
/// The received.
///
/// true if a message is received before the specified interval of time elapses; otherwise false.
///
public bool EndTryReceive(IAsyncResult result, out Message message)
{
message = null;
return TryDequeue(result, out message);
}
///
/// Tries to receive a message within a specified interval of time.
///
/// The returned by a call to one of the System.ServiceModel.Channels.IInputChannel.BeginReceive methods.
/// The received.
///
/// true if a message is received before the has been exceeded; otherwise false.
///
/// The specified is exceeded before the operation is completed.
/// The timeout specified is less than zero.
public bool TryReceive(TimeSpan timeout, out Message message)
{
message = Receive(timeout);
return true;
}
#endregion
#region WaitForMessage
///
/// Begins an asynchronous wait-for-a-message-to-arrive operation that has a specified time out and state object associated with it.
///
/// The that specifies the interval of time to wait for a message to become available.
/// The delegate that receives the notification of the asynchronous operation completion.
/// An object, specified by the application, that contains state information associated with the asynchronous operation.
///
/// The that references the asynchronous operation to wait for a message to arrive.
///
/// The specified is exceeded before the operation is completed.
/// The timeout specified is less than zero.
public IAsyncResult BeginWaitForMessage(TimeSpan timeout, AsyncCallback callback, object state)
{
throw new NotImplementedException();
}
///
/// Completes the specified asynchronous wait-for-a-message operation.
///
/// The that identifies the operation to finish, and from which to retrieve an end result.
///
/// true if a message has arrived before the has been exceeded; otherwise false.
///
public bool EndWaitForMessage(IAsyncResult result)
{
throw new NotImplementedException();
}
///
/// Returns a value that indicates whether a message has arrived within a specified interval of time.
///
/// The specifies the maximum interval of time to wait for a message to arrive before timing out.
///
/// true if a message has arrived before the has been exceeded; otherwise false.
///
/// The specified is exceeded before the operation is completed.
/// The timeout specified is less than zero.
public bool WaitForMessage(TimeSpan timeout)
{
throw new NotImplementedException();
}
#endregion
}
}