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. 27 // 28 29 30 using System; 31 using System.Collections; 32 using System.Runtime.Remoting; 33 34 using Unix = System.Runtime.Remoting.Channels.Ipc.Unix; 35 using Win32 = System.Runtime.Remoting.Channels.Ipc.Win32; 36 37 namespace System.Runtime.Remoting.Channels.Ipc 38 { 39 public class IpcServerChannel : IChannelReceiver, IChannel 40 { 41 IChannelReceiver _innerChannel; 42 string _portName; 43 IpcServerChannel(string portName)44 public IpcServerChannel (string portName) 45 { 46 _portName = portName; 47 48 if (IpcChannel.IsUnix) 49 _innerChannel = new Unix.IpcServerChannel (portName); 50 else 51 _innerChannel = new Win32.IpcServerChannel (portName); 52 } 53 IpcServerChannel(IDictionary properties, IServerChannelSinkProvider sinkProvider)54 public IpcServerChannel (IDictionary properties, 55 IServerChannelSinkProvider sinkProvider) 56 { 57 if (properties != null) 58 _portName = properties ["portName"] as string; 59 60 if (IpcChannel.IsUnix) 61 _innerChannel = new Unix.IpcServerChannel (properties, sinkProvider); 62 else 63 _innerChannel = new Win32.IpcServerChannel (properties, sinkProvider); 64 } 65 IpcServerChannel(string name, string portName, IServerChannelSinkProvider sinkProvider)66 public IpcServerChannel (string name, string portName, 67 IServerChannelSinkProvider sinkProvider) 68 { 69 _portName = portName; 70 71 if (IpcChannel.IsUnix) 72 _innerChannel = new Unix.IpcServerChannel (name, portName, sinkProvider); 73 else 74 _innerChannel = new Win32.IpcServerChannel (name, portName, sinkProvider); 75 } 76 IpcServerChannel(string name, string portName)77 public IpcServerChannel (string name, string portName) 78 { 79 _portName = portName; 80 81 if (IpcChannel.IsUnix) 82 _innerChannel = new Unix.IpcServerChannel (name, portName); 83 else 84 _innerChannel = new Win32.IpcServerChannel (name, portName); 85 } 86 87 public string ChannelName 88 { 89 get { return ((IChannel)_innerChannel).ChannelName; } 90 } 91 92 public int ChannelPriority 93 { 94 get { return ((IChannel)_innerChannel).ChannelPriority; } 95 } 96 Parse(string url, out string objectURI)97 public string Parse (string url, out string objectURI) 98 { 99 return ((IChannel)_innerChannel).Parse (url, out objectURI); 100 } 101 102 public object ChannelData 103 { 104 get { return _innerChannel.ChannelData; } 105 } 106 GetUrlsForUri(string objectUri)107 public virtual string[] GetUrlsForUri (string objectUri) 108 { 109 return _innerChannel.GetUrlsForUri (objectUri); 110 } 111 StartListening(object data)112 public void StartListening (object data) 113 { 114 _innerChannel.StartListening (data); 115 } 116 StopListening(object data)117 public void StopListening (object data) 118 { 119 _innerChannel.StopListening (data); 120 } 121 GetChannelUri()122 public string GetChannelUri () 123 { 124 // There is no interface for this member, 125 // so we cannot delegate to the inner channel. 126 return Win32.IpcChannelHelper.SchemeStart + _portName; 127 } 128 } 129 } 130 131