2010-06-21 Atsushi Enomoto <atsushi@ximian.com>
[mcs.git] / class / System.Runtime.Remoting / System.Runtime.Remoting.Channels.Ipc / IpcServerChannel.cs
blob061fc09be00fac2f5e5fa3aee4ab26c45304fd88
1 //
2 // System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.cs
3 //
4 // Author: Robert Jordan (robertj@gmx.net)
5 //
6 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
7 //
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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 #if NET_2_0
31 using System;
32 using System.Collections;
33 using System.Runtime.Remoting;
35 using Unix = System.Runtime.Remoting.Channels.Ipc.Unix;
36 using Win32 = System.Runtime.Remoting.Channels.Ipc.Win32;
38 namespace System.Runtime.Remoting.Channels.Ipc
40 public class IpcServerChannel : IChannelReceiver, IChannel
42 IChannelReceiver _innerChannel;
43 string _portName;
45 public IpcServerChannel (string portName)
47 _portName = portName;
49 if (IpcChannel.IsUnix)
50 _innerChannel = new Unix.IpcServerChannel (portName);
51 else
52 _innerChannel = new Win32.IpcServerChannel (portName);
55 public IpcServerChannel (IDictionary properties,
56 IServerChannelSinkProvider sinkProvider)
58 if (properties != null)
59 _portName = properties ["portName"] as string;
61 if (IpcChannel.IsUnix)
62 _innerChannel = new Unix.IpcServerChannel (properties, sinkProvider);
63 else
64 _innerChannel = new Win32.IpcServerChannel (properties, sinkProvider);
67 public IpcServerChannel (string name, string portName,
68 IServerChannelSinkProvider sinkProvider)
70 _portName = portName;
72 if (IpcChannel.IsUnix)
73 _innerChannel = new Unix.IpcServerChannel (name, portName, sinkProvider);
74 else
75 _innerChannel = new Win32.IpcServerChannel (name, portName, sinkProvider);
78 public IpcServerChannel (string name, string portName)
80 _portName = portName;
82 if (IpcChannel.IsUnix)
83 _innerChannel = new Unix.IpcServerChannel (name, portName);
84 else
85 _innerChannel = new Win32.IpcServerChannel (name, portName);
88 public string ChannelName
90 get { return ((IChannel)_innerChannel).ChannelName; }
93 public int ChannelPriority
95 get { return ((IChannel)_innerChannel).ChannelPriority; }
98 public string Parse (string url, out string objectURI)
100 return ((IChannel)_innerChannel).Parse (url, out objectURI);
103 public object ChannelData
105 get { return _innerChannel.ChannelData; }
108 public virtual string[] GetUrlsForUri (string objectUri)
110 return _innerChannel.GetUrlsForUri (objectUri);
113 public void StartListening (object data)
115 _innerChannel.StartListening (data);
118 public void StopListening (object data)
120 _innerChannel.StopListening (data);
123 public string GetChannelUri ()
125 // There is no interface for this member,
126 // so we cannot delegate to the inner channel.
127 return Win32.IpcChannelHelper.SchemeStart + _portName;
132 #endif