2 // MsmqChannelListener.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2007 Novell, Inc. http://www.novell.com
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections.Generic;
30 using System.Collections.ObjectModel;
31 using System.Messaging;
32 using System.ServiceModel;
33 using System.ServiceModel.Description;
34 using System.ServiceModel.Security;
37 namespace System.ServiceModel.Channels
39 internal class MsmqChannelListener<TChannel> : ChannelListenerBase<TChannel>
40 where TChannel : class, IChannel
42 MsmqTransportBindingElement source;
43 BindingContext context;
46 List<IChannel> channels = new List<IChannel> ();
47 MessageEncoder encoder;
49 public MsmqChannelListener (MsmqTransportBindingElement source,
50 BindingContext context)
51 : base (context.Binding)
53 if (context.ListenUriMode == ListenUriMode.Explicit)
54 listen_uri = new Uri (context.ListenUriBaseAddress, context.ListenUriRelativeAddress);
56 // FIXME: consider ListenUriMode.Unique
57 throw new NotImplementedException ();
59 foreach (BindingElement be in context.Binding.Elements) {
60 MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
62 encoder = CreateEncoder<TChannel> (mbe);
67 encoder = new BinaryMessageEncoder ();
70 public MessageQueue Queue {
74 public MessageEncoder MessageEncoder {
75 get { return encoder; }
78 public override Uri Uri {
79 get { return listen_uri; }
82 protected override TChannel OnAcceptChannel (TimeSpan timeout)
84 TChannel ch = PopulateChannel (timeout);
89 TChannel PopulateChannel (TimeSpan timeout)
91 if (typeof (TChannel) == typeof (IInputChannel)) {
92 return (TChannel) (object) new MsmqInputChannel (
93 (MsmqChannelListener<IInputChannel>) (object) this, timeout);
96 // FIXME: implement more
98 throw new NotImplementedException ();
101 protected override IAsyncResult OnBeginAcceptChannel (
102 TimeSpan timeout, AsyncCallback callback,
105 throw new NotImplementedException ();
108 protected override TChannel OnEndAcceptChannel (IAsyncResult result)
110 throw new NotImplementedException ();
113 protected override IAsyncResult OnBeginWaitForChannel (
114 TimeSpan timeout, AsyncCallback callback, object state)
116 throw new NotImplementedException ();
119 protected override bool OnEndWaitForChannel (IAsyncResult result)
121 throw new NotImplementedException ();
124 protected override bool OnWaitForChannel (TimeSpan timeout)
126 throw new NotImplementedException ();
129 void StartListening (TimeSpan timeout)
132 throw new InvalidOperationException ("This listener is already waiting for connection.");
134 queue = new MessageQueue (listen_uri.GetLeftPart (UriPartial.Scheme));
137 protected override void OnOpen (TimeSpan timeout)
139 StartListening (timeout);
142 protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
143 AsyncCallback callback, object state)
145 throw new NotImplementedException ();
148 protected override void OnEndOpen (IAsyncResult result)
150 throw new NotImplementedException ();
153 protected override void OnClose (TimeSpan timeout)
155 // FIXME: somewhere to use timeout?
162 protected override IAsyncResult OnBeginClose (TimeSpan timeout,
163 AsyncCallback callback, object state)
165 throw new NotImplementedException ();
169 protected override void OnEndClose (IAsyncResult result)
171 throw new NotImplementedException ();
174 [MonoTODO ("find out what to do here.")]
175 protected override void OnAbort ()