2 // System.Runtime.Remoting.Channels.Ipc.Win32.IpcChannel.cs
4 // Author: Robert Jordan (robertj@gmx.net)
6 // Copyright (C) 2005 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.
32 using System.Collections;
33 using System.Runtime.Remoting;
34 using System.Runtime.Remoting.Channels;
35 using System.Runtime.Remoting.Messaging;
37 namespace System.Runtime.Remoting.Channels.Ipc.Win32
39 internal class IpcChannel : IChannelSender, IChannelReceiver, IChannel
41 readonly IpcClientChannel clientChannel;
42 readonly IpcServerChannel serverChannel;
45 /// Creates a client channel.
49 clientChannel = new IpcClientChannel();
53 /// Creates a server channel.
55 /// <param name="portName">The port name.</param>
56 public IpcChannel(string portName)
59 serverChannel = new IpcServerChannel(portName);
63 /// Creates both server and client channels.
65 /// <param name="properties">The channel properties.</param>
66 /// <param name="clientProvider">The client sink provider. It may be <c>null</c>.</param>
67 /// <param name="serverProvider">The server sink provider. It may be <c>null</c>.</param>
68 public IpcChannel(IDictionary properties,
69 IClientChannelSinkProvider clientProvider,
70 IServerChannelSinkProvider serverProvider
73 clientChannel = new IpcClientChannel(properties, clientProvider);
74 serverChannel = new IpcServerChannel(properties, serverProvider);
77 #region IChannelSender Members
79 public IMessageSink CreateMessageSink(string url, object remoteChannelData, out string objectURI)
81 return clientChannel.CreateMessageSink(url, remoteChannelData, out objectURI);
86 #region IChannel Members
88 public string ChannelName
92 return serverChannel != null
93 ? serverChannel.ChannelName
94 : clientChannel.ChannelName;
98 public int ChannelPriority
102 return serverChannel != null
103 ? serverChannel.ChannelPriority
104 : clientChannel.ChannelPriority;
108 public string Parse(string url, out string objectURI)
110 return IpcChannelHelper.Parse(url, out objectURI);
115 #region IChannelReceiver Members
117 public void StartListening(object data)
119 serverChannel.StartListening(data);
122 public object ChannelData
126 return serverChannel != null ? serverChannel.ChannelData : null;
130 public void StopListening(object data)
132 serverChannel.StopListening(data);
135 public string[] GetUrlsForUri(string objectURI)
137 return serverChannel.GetUrlsForUri(objectURI);